#!/usr/bin/perl # # Cte ze stdin DEU a generuje z nich html stranku # Autor: Petr Mensik # use strict; my (@parameters); my %record; my %services; my %options; my $image_prefix = "icons/"; my $image_suffix = "png"; my $services_prefix = "/home/www/html/czf4bfu/services/"; my $image_systemprefix = "$services_prefix"; my $all_list = $services_prefix."index.html"; sub check_icon { my ($fileh,$svcname) = @_; my $webfile = "$image_prefix$svcname.$image_suffix"; my $file = "$image_systemprefix$webfile"; open(EXTRA, "< $file") || return 1; close(EXTRA); print $fileh "\"$svcname\""; return 0; # } else { # print STDERR "nepodarilo se $svcname\n"; return 1; # } } sub service_header { my ($svcname) = @_; open( SVC, "> $services_prefix$svcname.html") || return 1; print SVC " Seznam poskytovatelů služby $svcname

Poskytovatelé služby $svcname v síti CzFree.net

"; close(SVC); } sub service_footer { my ($svcname) = @_; open( SVC, ">> $services_prefix$svcname.html") || return 1; print SVC "

Nalezených služeb tohoto typu: $services{$svcname}

"; } # z jednoho deu udelej jeden HTML sub makeone { my ($file) = @_; if (!$file) { $file = $all_list; } open (SVC, ">> $file") || die "Nelze pridat zaznam do $file: $_"; print SVC "
\n"; print SVC "

\n"; if ($record{TYP}) { check_icon(\*SVC, $record{TYP}); } print SVC " $record{NAZEV}

\n"; print SVC "

"; print SVC "[$record{IDPOLOZKY}] "; print SVC " $record{TYP} "; if ($record{URL}) { print SVC "[dns] "; } if ($record{URLIP}) { print SVC "[ip-only] "; } if ($record{URLINET}) { print SVC "[internet] "; } if ($record{PRIVATNI}) { print SVC "(privátní) "; } print SVC "

\n"; print SVC "

$record{POPIS}

\n"; # print " #
typ
$record{TYP}
# "; if ($record{OBLASTI}) { print SVC "
oblasti
$record{OBLASTI}
"; } if ($record{IP}) { print SVC "
hostname
$record{HOST}
"; } if ($record{IP}) { print SVC "
IP
$record{IP}
"; } if ($record{KONTAKT}) { my $kontakt = $record{KONTAKT}; print SVC "
kontakt
$record{KONTAKT}
"; } if ($record{ORIGIN}) { print SVC "
původ
$record{ORIGIN}
"; } if ($record{ALT}) { print SVC "
alternativní
$record{ALT}
"; } print SVC "
"; close(SVC); } #getopts("", \%options ); open(SVC, "> $all_list"); print SVC " Seznam služeb z CZF4BFU listu

Seznam všech nalezených služeb

"; close(SVC); foreach my $file (@ARGV) { open(DEU, "< $file") || die("Chyba otevirani $file"); print "Processing $file\n"; while () { chomp; # pokus o ostraneni dosoveho CR $_ =~ s/\r$//; if (/^\s*$/ && $record{TYP}) { # prazdny radek, oddelovac # pokud nenacteme aspon prvni TYP, nedelame nic. # ochrana proti vice prazdnym radkum $record{FILE}= $file; $record{ORIGIN} = $file; $record{ORIGIN} =~ s/.*global-(\d+\.\d+\.\d+\.\d+).txt$/\1/; makeone($all_list,\%record); my $typ = $record{TYP}; if (!$services{$typ}) { print "New service $typ\n"; service_header($typ); $services{$typ} = 0; } makeone("$services_prefix$typ.html"); $services{$typ}++; %record = (); } elsif (/^([A-Zi]+):\s*(.*)\s{0,1}$/) { # jelikoz se zda, ze prvni zaznam ma prioritu pred nasledujicimi, budu pro # jednoduchost mit jenom prvni zaznam tak, ze ty dalsi ignoruju $record{$1} = $2 unless ($record{$1}); # print "dbg: $1 $2 $record{URL}\n"; } else { print STDERR "Nepodporovany radek $_\n."; } } # while close(DEU); } # foreach open (SVC, ">> $all_list") || die "Nelze pridat do $all_list"; print SVC " "; foreach my $typ (keys %services) { service_footer($typ); } close(SVC); WebSVN - czf4bfu.prosek.czf - Blame - Rev 4 - /zal/genservices.pl
  jablonka.czprosek.czf

czf4bfu.prosek.czf

Subversion Repositories:
[/] [zal/] [genservices.pl] - Blame information for rev 4

 

Line No. Rev Author Line

Powered by WebSVN 2.2.1