lilalo
view l3-frontend @ 63:1864df6ccbfe
Новые команды дня разбиваются по секциям
| author | devi | 
|---|---|
| date | Fri Jan 27 00:06:41 2006 +0200 (2006-01-27) | 
| parents | c4bea959dbb1 | 
| children | 3326053f9b23 | 
 line source
     1 #!/usr/bin/perl -w
     3 use IO::Socket;
     4 use lib '.';
     5 use l3config;
     6 use locale;
     8 our @Command_Lines;
     9 our @Command_Lines_Index;
    10 our %Commands_Description;
    11 our %Args_Description;
    12 our $Mywi_Socket;
    13 our %Sessions;
    15 # vvv Инициализация переменных выполняется процедурой init_variables
    16 our @Day_Name;
    17 our @Month_Name;
    18 our @Of_Month_Name;
    19 our %Search_Machines;
    20 our %Elements_Visibility;
    21 # ^^^
    23 our %Stat;
    24 our %CommandsFDistribution; # Сколько раз в журнале встречается какая команда
    25 our $table_number=1;
    27 my %mywi_cache_for;         # Кэш для экономии обращений к mywi
    29 sub make_comment;
    30 sub make_new_entries_table;
    31 sub load_command_lines_from_xml;
    32 sub load_sessions_from_xml;
    33 sub sort_command_lines;
    34 sub process_command_lines;
    35 sub init_variables;
    36 sub main;
    37 sub collapse_list($);
    39 sub print_all;
    40 sub print_command_lines;
    41 sub print_stat;
    42 sub print_header;
    43 sub print_footer;
    45 main();
    47 sub main
    48 {
    49     $| = 1;
    51     init_variables();
    52     init_config();
    54     open_mywi_socket();
    55     load_command_lines_from_xml($Config{"backend_datafile"});
    56     load_sessions_from_xml($Config{"backend_datafile"});
    57     sort_command_lines;
    58     process_command_lines;
    59     print_all($Config{"output"});
    60     close_mywi_socket;
    61 }
    63 # extract_from_cline
    65 # In:   $what       = commands | args
    66 # Out:  return      ссылка на хэш, содержащий результаты разбора
    67 #                   команда => позиция
    69 # Разобрать командную строку $_[1] и возвратить хэш, содержащий 
    70 # номер первого появление команды в строке:
    71 #   команда => первая позиция
    72 sub extract_from_cline
    73 {
    74     my $what = $_[0];
    75     my $cline = $_[1];
    76     my @lists = split /\;/, $cline;
    79     my @command_lines = ();
    80     for my $command_list (@lists) {
    81         push(@command_lines, split(/\|/, $command_list));
    82     }
    84     my %position_of_command;
    85     my %position_of_arg;
    86     my $i=0;
    87     for my $command_line (@command_lines) {
    88         $command_line =~ s@^\s*@@;
    89         $command_line =~ /\s*(\S+)\s*(.*)/;
    90         if ($1 && $1 eq "sudo" ) {
    91             $position_of_command{"$1"}=$i++;
    92             $command_line =~ s/\s*sudo\s+//;
    93         }
    94         if ($command_line !~ m@^\s*\S*/etc/@) {
    95             $command_line =~ s@^\s*\S+/@@;
    96         }
    98         $command_line =~ /\s*(\S+)\s*(.*)/;
    99         my $command = $1;
   100         my $args = $2;
   101         if ($command && !defined $position_of_command{"$command"}) {
   102                 $position_of_command{"$command"}=$i++;
   103         };  
   104         if ($args) {
   105             my @args = split (/\s+/, $args);
   106             for my $a (@args) {
   107                 $position_of_arg{"$a"}=$i++
   108                     if !defined $position_of_arg{"$a"};
   109             };  
   110         }
   111     }
   113     if ($what eq "commands") {
   114         return \%position_of_command;
   115     } else {
   116         return \%position_of_arg;
   117     }
   119 }
   124 #
   125 # Подпрограммы для работы с mywi
   126 #
   128 sub open_mywi_socket
   129 {
   130     $Mywi_Socket = IO::Socket::INET->new(
   131                 PeerAddr => $Config{mywi_server},
   132                 PeerPort => $Config{mywi_port},
   133                 Proto    => "tcp",
   134                 Type     => SOCK_STREAM);
   135 }
   137 sub close_mywi_socket
   138 {
   139     close ($Mywi_Socket) if $Mywi_Socket ;
   140 }
   143 sub mywi_client
   144 {
   145     my $query = $_[0];
   146     my $mywi;
   148     open_mywi_socket;
   149     if ($Mywi_Socket) {
   150         local $| = 1;
   151         local $/ = "";
   152         print $Mywi_Socket $query."\n";
   153         $mywi = <$Mywi_Socket>;
   154         $mywi = "" if $mywi =~ /nothing app/;
   155     }
   156     close_mywi_socket;
   157     return $mywi;
   158 }
   160 sub make_comment
   161 {
   162     my $cline = $_[0];
   163     #my $files = $_[1];
   165     my @comments;
   166     my @commands = keys %{extract_from_cline("commands", $cline)};
   167     my @args = keys %{extract_from_cline("args", $cline)};
   168     return if (!@commands && !@args);
   169     #return "commands=".join(" ",@commands)."; files=".join(" ",@files);
   171     # Commands
   172     for my $command (@commands) {
   173         $command =~ s/'//g;
   174         $CommandsFDistribution{$command}++;
   175         if (!$Commands_Description{$command}) {
   176             $mywi_cache_for{$command} ||= mywi_client ($command) || "";
   177             my $mywi = join ("\n", grep(/\([18]|sh|script\)/, split(/\n/, $mywi_cache_for{$command})));
   178             $mywi =~ s/\s+/ /;
   179             if ($mywi !~ /^\s*$/) {
   180                 $Commands_Description{$command} = $mywi;
   181             }
   182             else {
   183                 next;
   184             }
   185         }
   187         push @comments, $Commands_Description{$command};
   188     }
   189     return join("
\n", @comments);
   191     # Files
   192     for my $arg (@args) {
   193         $arg =~ s/'//g;
   194         if (!$Args_Description{$arg}) {
   195             my $mywi;
   196             $mywi = mywi_client ($arg);
   197             $mywi = join ("\n", grep(/\([5]\)/, split(/\n/, $mywi)));
   198             $mywi =~ s/\s+/ /;
   199             if ($mywi !~ /^\s*$/) {
   200                 $Args_Description{$arg} = $mywi;
   201             }
   202             else {
   203                 next;
   204             }
   205         }
   207         push @comments, $Args_Description{$arg};
   208     }
   210 }
   212 =cut
   213 Процедура load_command_lines_from_xml выполняет загрузку разобранного lab-скрипта
   214 из XML-документа в переменную @Command_Lines
   216 # In:       $datafile           имя файла
   217 # Out:      @CommandLines       загруженные командные строки
   219 Предупреждение!
   220 Процедура не в состоянии обрабатывать XML-документ любой структуры.
   221 В действительности файл cache из которого загружаются данные 
   222 просто напоминает XML с виду.
   223 =cut
   224 sub load_command_lines_from_xml
   225 {
   226     my $datafile = $_[0];
   228     open (CLASS, $datafile)
   229         or die "Can't open file of the class ",$datafile,"\n";
   230     local $/;
   231     $data = <CLASS>;
   232     close(CLASS);
   234     for $command ($data =~ m@<command>(.*?)</command>@sg) {
   235         my %cl;
   236         while ($command =~ m@<([^>]*?)>(.*?)</\1>@sg) {
   237             $cl{$1} = $2;
   238         }
   239         push @Command_Lines, \%cl;
   240     }
   241 }
   243 sub load_sessions_from_xml
   244 {
   245     my $datafile = $_[0];
   247     open (CLASS, $datafile)
   248         or die "Can't open file of the class ",$datafile,"\n";
   249     local $/;
   250     my $data = <CLASS>;
   251     close(CLASS);
   253     for my $session ($data =~ m@<session>(.*?)</session>@sg) {
   254         my %session;
   255         while ($session =~ m@<([^>]*?)>(.*?)</\1>@sg) {
   256             $session{$1} = $2;
   257         }
   258         $Sessions{$session{local_session_id}} = \%session;
   259     }
   260 }
   263 # sort_command_lines
   264 # In:   @Command_Lines
   265 # Out:  @Command_Lies_Index
   267 sub sort_command_lines
   268 {
   270     my @index;
   271     for (my $i=0;$i<=$#Command_Lines;$i++) {
   272         $index[$i]=$i;
   273     }
   275     @Command_Lines_Index = sort {
   276         $Command_Lines[$index[$a]]->{"time"} <=> $Command_Lines[$index[$b]]->{"time"}
   277     } @index;
   279 }
   281 ##################
   282 # process_command_lines
   283 #
   284 # Обрабатываются командные строки @Command_Lines
   285 # Для каждой строки определяется:
   286 #   class   класс    
   287 #   note    комментарий 
   288 #
   289 # In:        @Command_Lines_Index
   290 # In-Out:    @Command_Lines
   292 sub process_command_lines
   293 {
   294     for my $i (@Command_Lines_Index) {
   295         my $cl = \$Command_Lines[$i];
   297         next if !$cl;
   299         $$cl->{err} ||=0;
   301         # Класс команды
   303         $$cl->{"class"} =   $$cl->{"err"} eq 130 ?  "interrupted"
   304                         :   $$cl->{"err"} eq 127 ?  "mistyped"
   305                         :   $$cl->{"err"}        ?  "wrong"
   306                         :                           "normal";
   308         if ($$cl->{"cline"} =~ /[^|`]\s*sudo/
   309             || $$cl->{"uid"} eq 0) {
   310             $$cl->{"class"}.="_root";
   311         }
   314 #Обработка пометок
   315 #  Если несколько пометок (notes) идут подряд, 
   316 #  они все объединяются
   318         if ($$cl->{cline}=~ m@cat[^#]*#([\^=v])\s*(.*)@) {
   320             my $note_operator = $1;
   321             my $note_title = $2;
   323             if ($note_operator eq "=") {
   324                 $$cl->{"class"} = "note";
   325                 $$cl->{"note"} = $$cl->{"output"};
   326                 $$cl->{"note_title"} = $2;
   327             }
   328             else {
   329                 my $j = $i;
   330                 if ($note_operator eq "^") {
   331                     $j--;
   332                     $j-- while ($j >=0  && (!$Command_Lines[$j] || $Command_Lines[$j]->{tty} ne $$cl->{tty}));
   333                 }
   334                 elsif ($note_operator eq "v") {
   335                     $j++;
   336                     $j++ while ($j <= @Command_Lines  && (!$Command_Lines[$j] || $Command_Lines[$j]->{tty} ne $$cl->{tty}));
   337                 }
   338                 $Command_Lines[$j]->{note_title}=$note_title;
   339                 $Command_Lines[$j]->{note}.=$$cl->{output};
   340                 $$cl=0;
   341             }
   342         }
   343         elsif ($$cl->{cline}=~ /#([\^=v])(.*)/) {
   345             my $note_operator = $1;
   346             my $note_text = $2;
   348             if ($note_operator eq "=") {
   349                 $$cl->{"class"} = "note";
   350                 $$cl->{"note"} = $note_text;
   351             }
   352             else {
   353                 my $j=$i;
   354                 if ($note_operator eq "^") {
   355                     $j--;
   356                     $j-- while ($j >=0  && (!$Command_Lines[$j] || $Command_Lines[$j]->{tty} ne $$cl->{tty}));
   357                 }
   358                 elsif ($note_operator eq "v") {
   359                     $j++;
   360                     $j++ while ($j <= @Command_Lines  && $Command_Lines[$j]->{tty} ne $$cl->{tty} || !$Command_Lines[$j]);
   361                 }
   362                 $Command_Lines[$j]->{note}.="$note_text\n";
   363                 $$cl=0;
   364             }
   365         }
   366     }   
   368 }
   371 =cut
   372 Процедура print_command_lines выводит HTML-представление
   373 разобранного lab-скрипта. 
   375 Разобранный lab-скрипт должен находиться в массиве @Command_Lines
   376 =cut
   378 sub print_command_lines
   379 {
   381     my @toc;                # Оглавление
   382     my $note_number=0;
   384     my $result = q();
   385     my $this_day_resut = q();
   387     my $cl;
   388     my $last_tty="";
   389     my $last_day=q();
   390     my $last_wday=q();
   391     my $in_range=0;
   393     my $current_command=0;
   395     my @known_commands;
   397     my %filter;
   399     if ($Config{filter}) {
   400         # Инициализация фильтра
   401         for (split /&/,$Config{filter}) {
   402             my ($var, $val) = split /=/;
   403             $filter{$var} = $val || "";
   404         }
   405     }
   407     #$result = "Filter=".$Config{filter}."\n";
   409     $Stat{LastCommand}   ||= 0;
   410     $Stat{TotalCommands} ||= 0;
   411     $Stat{ErrorCommands} ||= 0;
   412     $Stat{MistypedCommands} ||= 0;
   414     my %new_entries_of = (
   415         "1"     =>   "программы пользователя",
   416         "8"     =>   "программы администратора",
   417         "sh"    =>   "команды интерпретатора",
   418         "script"=>   "скрипты",
   419     );
   421 COMMAND_LINE:
   422     for my $k (@Command_Lines_Index) {
   424         my $cl=$Command_Lines[$Command_Lines_Index[$current_command++]];
   425         next unless $cl;
   427 # Пропускаем команды, с одинаковым временем
   428 # Это не совсем правильно.
   429 # Возможно, что это команды, набираемые с помощью <completion>
   430 # или запомненные с помощью <ctrl-c>
   432         next if $Stat{LastCommand} == $cl->{time};
   434 # Набираем статистику
   435 # Хэш %Stat
   437         $Stat{FirstCommand} = $cl->{time} unless $Stat{FirstCommand};
   438         if ($cl->{time} - $Stat{LastCommand} < $Config{stat_inactivity_interval}) {
   439             $Stat{TotalTime} += $cl->{time} - $Stat{LastCommand}
   440         }
   441         $Stat{LastCommand} = $cl->{time};
   442         $Stat{TotalCommands}++;
   444 # Пропускаем строки, которые противоречат фильтру
   445 # Если у нас недостаточно информации о том, подходит строка под  фильтр или нет, 
   446 # мы её выводим
   448         #$result .= "before<br/>";
   449         for my $filter_key (keys %filter) {
   450             #$result .= "undefined local session id<br/>\n" if !defined($cl->{local_session_id});
   451             #$result .= "undefined filter key $filter_key <br/>\n" if !defined($Sessions{$cl->{local_session_id}}->{$filter_key});
   452             #$result .= $Sessions{$cl->{local_session_id}}->{$filter_key}." != ".$filter{$filter_key};
   453             next COMMAND_LINE if 
   454                 defined($cl->{local_session_id}) 
   455                 && defined($Sessions{$cl->{local_session_id}}->{$filter_key}) 
   456                 && $Sessions{$cl->{local_session_id}}->{$filter_key} ne $filter{$filter_key};
   457         }
   459 # Пропускаем строки, выходящие за границу "signature",
   460 # при условии, что границы указаны
   461 # Пропускаем неправильные/прерванные/другие команды
   462         if ($Config{"from"} && $cl->{"cline"} =~ /$Config{"signature"}\s*$Config{"from"}/) {
   463             $in_range=1;
   464             next;
   465         }
   466         if ($Config{"to"} && $cl->{"cline"} =~ /$Config{"signature"}\s*$Config{"to"}/) {
   467             $in_range=0;
   468             next;
   469         }
   470         next    if ($Config{"from"} && $Config{"to"}   && !$in_range) 
   471                 || ($Config{"skip_empty"} =~ /^y/i     && $cl->{"cline"} =~ /^\s*$/ )
   472                 || ($Config{"skip_wrong"} =~ /^y/i     && $cl->{"err"} != 0)
   473                 || ($Config{"skip_interrupted"} =~ /^y/i && $cl->{"err"} == 130);
   475         if ($cl->{class} eq "note") {
   476             my $note = $cl->{note};
   477             $note = join ("\n", map ("<p>$_</p>", split (/-\n/, $note)));
   478             $note =~ s@(http:[a-zA-Z.0-9/?\_%-]*)@<a href='$1'>$1</a>@g;
   479             $note =~ s@(www\.[a-zA-Z.0-9/?\_%-]*)@<a href='$1'>$1</a>@g;
   480             $this_day_result .= "<tr><td colspan='6'>"
   481                              .  "<h4 id='note$note_number'>".$cl->{note_title}."</h4>" if $cl->{note_title}
   482                              .  "".$note."<p/><p/></td></tr>";
   484             if ($cl->{note_title}) {
   485                 push @{$toc[@toc]},"<a href='#note$note_number'>".$cl->{note_title}."</a>";
   486                 $note_number++;
   487             }
   488             next;
   489         }
   492         my $output="";
   493 # Выводим <head_lines> верхних строк
   494 # и <tail_lines> нижних строк,
   495 # если эти параметры существуют
   497         my @lines = split '\n', $cl->{"output"};
   498         if (($Config{"head_lines"} || $Config{"tail_lines"})
   499              && $#lines >  $Config{"head_lines"} + $Config{"tail_lines"} ) {
   501             for (my $i=0; $i<= $#lines && $i < $Config{"head_lines"}; $i++) {
   502                 $output .= $lines[$i]."\n";
   503             }
   504             $output .= $Config{"skip_text"}."\n";
   506             my $start_line=$#lines-$Config{"tail_lines"}+1;
   507             for ($i=$start_line; $i<= $#lines; $i++) {
   508                 $output .= $lines[$i]."\n";
   509             }
   510         } 
   511         else {
   512             $output .= $cl->{"output"};
   513         }   
   515 #
   516 ##
   517 ## Начинается собственно вывод
   518 ##
   519 #
   521         my ($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst) = localtime($cl->{time});
   523         # Добавляем спереди 0 для удобочитаемости
   524         $min  = "0".$min  if $min  =~ /^.$/;
   525         $hour = "0".$hour if $hour =~ /^.$/;
   526         $sec  = "0".$sec  if $sec  =~ /^.$/;
   528         $class=$cl->{"class"};
   529         $Stat{ErrorCommands}++          if $class =~ /wrong/;
   530         $Stat{MistypedCommands}++       if $class =~ /mistype/;
   533 # DAY CHANGE
   534         if ( $last_day ne $day) {
   535             if ($last_day) {
   537 # Вычисляем разность множеств.
   538 # Что-то вроде этого, если бы так можно было писать:
   539 #   @new_commands = keys %CommandsFDistribution - @known_commands;
   542                 $result .= "<h3 id='day$last_day'>".$Day_Name[$last_wday]."</h3>";
   546                 for my $entry_class (keys %new_entries_of) {
   547                     my $new_commands_section = make_new_entries_table("$entry_class", \@known_commands);
   549                     my $table_caption = "Таблица ".$table_number++.". Новые ".$new_entries_of{$entry_class}.". ".$Day_Name[$last_wday];
   550                     if ($new_commands_section) {
   551                         $result .= "<table class='new_commands_table'>"
   552                                 .  "<tr class='new_commands_caption'><td colspan='2' align='right'>$table_caption</td></tr>"
   553                                 .  "<tr class='new_commands_header'><td>Команда</td><td>Описание</td></tr>"
   554                                 .  $new_commands_section 
   555                                 .  "</table>"
   556                     }
   558                 }
   559                 @known_commands = keys %CommandsFDistribution;
   560                 $result .= "<table width='100%'>\n";
   561                 $result .= $this_day_result;
   562                 $result .= "</table>";
   563             }
   565             push @toc, "<a href='#day$day'>".$Day_Name[$wday]."</a>\n";
   566             $last_day=$day;
   567             $last_wday=$wday;
   568             $this_day_result = q();
   569         }
   571         $this_day_result .= "<tr class='command'>\n";
   574 # CONSOLE CHANGE
   575         if ( $last_tty ne $cl->{"tty"}) {
   576             my $tty = $cl->{"tty"};
   577             $this_day_result .= "<td colspan='6'>"
   578                                 ."<table><tr><td class='ttychange' width='140' align='center'>"
   579                                 . $tty
   580                                 ."</td></tr></table>"
   581                                 ."</td></tr><tr>";
   582             $last_tty=$cl->{"tty"};
   583         }
   585 # TIME
   586         $this_day_result .= $Config{"show_time"} =~ /^y/i
   587                  ? "<td valign='top' class='time' width='$Config{time_width}'>$hour:$min:$sec</td>"
   588                  : "<td width='0'/>";
   590 # COMMAND
   591         my $hint = make_comment($cl->{"cline"});
   593         my $cline;
   594         $cline = $cl->{"prompt"}.$cl->{"cline"};
   595         $cline =~ s/\n//;
   597         $cline = "<span title='$hint' class='with_hint'>$cline</span>" if $hint;
   598         $cline = "<span class='without_hint'>$cline</span>" if !$hint;
   600         $this_day_result .= "<td class='script'>\n";
   601         $this_day_result .= "<pre class='${class}_cline'>\n" . $cline . "</pre>\n";
   603 # OUTPUT
   604         my $last_command = $cl->{"last_command"};
   605         if (!( 
   606         $Config{"suppress_editors"} =~ /^y/i && grep ($_ eq $last_command, @{$Config{"editors"}}) ||
   607         $Config{"suppress_pagers"}  =~ /^y/i && grep ($_ eq $last_command, @{$Config{"pagers"}}) ||
   608         $Config{"suppress_terminal"}=~ /^y/i && grep ($_ eq $last_command, @{$Config{"terminal"}})
   609             )) {
   610             $this_day_result .= "<pre class='".$class."_output'>" . $output . "</pre>\n";
   611         }   
   613 # DIFF
   614         if ( $Config{"show_diffs"} =~ /^y/i && $cl->{"diff"}) {
   615             $this_day_result .= "<table><tr><td width='5'/><td class='diff'><pre>"
   616                     .  $cl->{"diff"}
   617                     .  "</pre></td></tr></table>";
   618         }
   620 #NOTES
   621         if ( $Config{"show_notes"} =~ /^y/i && $cl->{"note"}) {
   622             my $note=$cl->{"note"};
   623             $note =~ s/\n/<br\/>\n/msg;
   624             if (not $note =~ s@(http:[a-zA-Z.0-9/_?%-]*)@<a href='$1'>$1</a>@g) {
   625               $note =~ s@(www\.[a-zA-Z.0-9/_?%-]*)@<a href='$1'>$1</a>@g;
   626             };
   627         #   Ширину пока не используем
   628         #   $this_day_result .= "<table width='$Config{note_width}' class='note'>";
   629             $this_day_result .= "<table class='note'>";
   630             $this_day_result .= "<tr><td class='note_title'>".$cl->{note_title}."</td></tr>" if $cl->{note_title};
   631             $this_day_result .= "<tr><td width='100%' class='note_text'>".$note."</td></tr>";
   632             $this_day_result .= "</table>\n";
   633         }
   635 # COMMENT
   636         if ( $Config{"show_comments"} =~ /^y/i) {
   637             my $comment = make_comment($cl->{"cline"});
   638             if ($comment) {
   639                 $this_day_result .= "<table width='$Config{comment_width}'><tr><td width='5'/><td>"
   640                         .  "<table class='note' width='100%'>"
   641                         .  $comment
   642                         .  "</table>\n"
   643                         .  "</td></tr></table>";
   644             }
   645         }
   647         # Вывод очередной команды окончен
   648         $this_day_result .= "</td>\n";
   649         $this_day_result .= "</tr>\n";
   650     }
   651     last: {
   652         $result .= "<h3 id='day$last_day'>".$Day_Name[$last_wday]."</h3>";
   654         for my $entry_class (keys %new_entries_of) {
   655             my $new_commands_section = make_new_entries_table("$entry_class", \@known_commands);
   656             @known_commands = keys %CommandsFDistribution;
   658             my $table_caption = "Таблица ".$table_number++.". Новые ".$new_entries_of{$entry_class}. ". ".$Day_Name[$last_wday];
   659             if ($new_commands_section) {
   660                 $result .= "<table class='new_commands_table'>"
   661                         .  "<tr class='new_commands_caption'><td colspan='2' align='right'>$table_caption</td></tr>"
   662                         .  "<tr class='new_commands_header'><td>Команда</td><td>Описание</td></tr>"
   663                         .  $new_commands_section 
   664                         .  "</table>"
   665                         ;
   666             }
   668         }
   670         $result .= "<table width='100%'>\n";
   671         $result .= $this_day_result;
   672         $result .= "</table>";
   673    }
   675     return ($result, collapse_list (\@toc));
   677 }
   679 sub make_new_entries_table
   680 {
   681     my $entries_class = shift;
   682     my @known_commands = @{$_[0]};
   684     my %count;
   685     my @new_commands = ();
   686     for my $c (keys %CommandsFDistribution, @known_commands) {
   687         $count{$c}++
   688     }
   689     for my $c (keys %CommandsFDistribution) {
   690         push @new_commands, $c if $count{$c} != 2;
   691     }
   694     my $new_commands_section;
   695     if (@new_commands){
   696         my $hint;
   697         for my $c (reverse sort { $CommandsFDistribution{$a} <=> $CommandsFDistribution{$b} } @new_commands) {
   698                 $hint = make_comment($c);
   699                 my ($command, $hint) = $hint =~ m/(.*?) \s*- \s*(.*)/;
   700                 next unless $command =~ /\($entries_class\)/i;
   701                 $new_commands_section .= "<tr><td valign='top'>$command</td><td>$hint</td></tr>"  if $hint;
   702         }
   703     }
   704     return $new_commands_section;
   705 }
   708 #############
   709 # print_all
   710 #
   711 #
   712 #
   713 # In:       $_[0]       output_filename
   714 # Out:
   717 sub print_all
   718 {
   719     my $output_filename=$_[0];
   721     my $result;
   722     my ($command_lines,$toc)  = print_command_lines;
   724     $result = print_header($toc);
   725     $result.= "<h2 id='log'>Журнал</h2>"       . $command_lines;
   726     $result.= "<h2 id='stat'>Статистика</h2>"  . print_stat;
   727     $result.= "<h2 id='help'>Справка</h2>"     . $Html_Help . "<br/>"; 
   728     $result.= "<h2 id='about'>О программе</h2>". $Html_About. "<br/>"; 
   729     $result.= print_footer;
   731     if ($output_filename eq "-") {
   732         print $result;
   733     }
   734     else {
   735         open(OUT, ">", $output_filename)
   736             or die "Can't open $output_filename for writing\n";
   737         print OUT $result;
   738         close(OUT);
   739     }
   740 }
   742 #############
   743 # print_header
   744 #
   745 #
   746 #
   747 # In:   $_[0]       Содержание
   748 # Out:              Распечатанный заголовок
   750 sub print_header
   751 {
   752     my $toc = $_[0];
   753     my $course_name = $Config{"course-name"};
   754     my $course_code = $Config{"course-code"};
   755     my $course_date = $Config{"course-date"};
   756     my $course_center = $Config{"course-center"};
   757     my $course_trainer = $Config{"course-trainer"};
   758     my $course_student = $Config{"course-student"};
   760     my $title    = "Журнал лабораторных работ";
   761     $title      .= " -- ".$course_student if $course_student;
   762     if ($course_date) {
   763         $title  .= " -- ".$course_date; 
   764         $title  .= $course_code ? "/".$course_code 
   765                                 : "";
   766     }
   767     else {
   768         $title  .= " -- ".$course_code if $course_code;
   769     }
   771     # Управляющая форма
   772     my $control_form .= "<table id='visibility_form' class='visibility_form'><tr><td>Видимые элементы</TD></tr><tr><td><form>\n";
   773     for my $element (keys %Elements_Visibility)
   774     {
   775         my @e = split /\s+/, $element;
   776         my $showhide = join "", map { "ShowHide('$_');" } @e ;
   777         $control_form .= "<input type='checkbox' name='$e[0]' onclick=\"$showhide\" checked>".
   778                 $Elements_Visibility{$element}.
   779                 "</input><br>\n";
   780     }
   781     $control_form .= "</form></td></tr></table>\n";
   783     my $result;
   784     $result = <<HEADER;
   785     <html>
   786     <head>
   787     <meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
   788     <link rel='stylesheet' href='$Config{frontend_css}' type='text/css'/>
   789     <title>$title</title>
   790     </head>
   791     <body>
   792     <script>
   793     $Html_JavaScript
   794     </script>
   796 <!-- vvv Tigra Hints vvv -->
   797 <script language="JavaScript" src="/tigra/hints.js"></script>
   798 <script language="JavaScript" src="/tigra/hints_cfg.js"></script>
   799 <style>
   800 /* a class for all Tigra Hints boxes, TD object */
   801     .hintsClass
   802         {text-align: center; font-family: Verdana, Arial, Helvetica; padding: 0px 0px 0px 0px;}
   803 /* this class is used by Tigra Hints wrappers */
   804     .row
   805         {background: white;}
   806 </style>
   807 <!-- ^^^ Tigra Hints ^^^ -->
   810     <h1 onmouseover="myHint.show('1')" onmouseout="myHint.hide()">Журнал лабораторных работ</h1>
   811 HEADER
   812     if (    $course_student 
   813             || $course_trainer 
   814             || $course_name 
   815             || $course_code 
   816             || $course_date 
   817             || $course_center) {
   818             $result .= "<p>";
   819             $result .= "Выполнил $course_student<br/>"  if $course_student;
   820             $result .= "Проверил $course_trainer <br/>" if $course_trainer;
   821             $result .= "Курс "                          if $course_name 
   822                                                             || $course_code 
   823                                                             || $course_date;
   824             $result .= "$course_name "                  if $course_name;
   825             $result .= "($course_code)"                 if $course_code;
   826             $result .= ", $course_date<br/>"            if $course_date;
   827             $result .= "Учебный центр $course_center <br/>" if $course_center;
   828             $result .= "</p>";
   829     }
   831     $result .= <<HEADER;
   832     <table width='100%'>
   833     <tr>
   834     <td width='*'>
   836     <table border=0 id='toc' class='toc'>
   837     <tr>
   838     <td>
   839     <div class='toc_title'>Содержание</div>
   840     <ul>
   841         <li><a href='#log'>Журнал</a></li>
   842         <ul>$toc</ul>
   843         <li><a href='#stat'>Статистика</a></li>
   844         <li><a href='#help'>Справка</a></li>
   845         <li><a href='#about'>О программе</a></li>
   846     </ul>
   847     </td>
   848     </tr>
   849     </table>
   851     </td>
   852     <td valign='top' width=200>$control_form</td>
   853     </tr>
   854     </table>
   855 HEADER
   857     return $result;
   858 }
   861 #############
   862 # print_footer
   863 #
   864 #
   865 #
   866 #
   867 #
   869 sub print_footer
   870 {
   871     return "</body>\n</html>\n";
   872 }
   877 #############
   878 # print_stat
   879 #
   880 #
   881 #
   882 # In:
   883 # Out:
   885 sub print_stat
   886 {
   887     %StatNames = (
   888         FirstCommand        => "Время первой команды журнала",
   889         LastCommand         => "Время последней команды журнала",
   890         TotalCommands       => "Количество командных строк в журнале",
   891         ErrorsPercentage    => "Процент команд с ненулевым кодом завершения, %",
   892         MistypesPercentage  => "Процент синтаксически неверно набранных команд, %",
   893         TotalTime           => "Суммарное время работы с терминалом <sup><font size='-2'>*</font></sup>, час",
   894         CommandsPerTime     => "Количество командных строк в единицу времени, команда/мин",
   895         CommandsFrequency   => "Частота использования команд",
   896         RareCommands        => "Частота использования этих команд < 0.5%",
   897     );
   898     @StatOrder = (
   899         FirstCommand,
   900         LastCommand,
   901         TotalCommands,
   902         ErrorsPercentage,
   903         MistypesPercentage,
   904         TotalTime,
   905         CommandsPerTime,
   906         CommandsFrequency,
   907         RareCommands,
   908     );
   910     # Подготовка статистики к выводу
   911     # Некоторые значения пересчитываются!
   912     # Дальше их лучше уже не использовать!!!
   914     my %CommandsFrequency = %CommandsFDistribution;
   916     $Stat{TotalTime} ||= 0;
   917     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Stat{FirstCommand} || 0);
   918     $Stat{FirstCommand} = sprintf "%02i:%02i:%02i %04i-%2i-%2i", $hour, $min, $sec,  $year+1900, $mon+1, $mday;
   919     ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Stat{LastCommand} || 0);
   920     $Stat{LastCommand} = sprintf "%02i:%02i:%02i %04i-%2i-%2i", $hour, $min, $sec,  $year+1900, $mon+1, $mday;
   921     if ($Stat{TotalCommands}) {
   922         $Stat{ErrorsPercentage} = sprintf "%5.2f", $Stat{ErrorCommands}*100/$Stat{TotalCommands};
   923         $Stat{MistypesPercentage} = sprintf "%5.2f", $Stat{MistypedCommands}*100/$Stat{TotalCommands};
   924     }
   925     $Stat{CommandsPerTime} = sprintf "%5.2f", $Stat{TotalCommands}*60/$Stat{TotalTime}
   926         if $Stat{TotalTime};
   927     $Stat{TotalTime} = sprintf "%5.2f", $Stat{TotalTime}/60/60;
   929     my $total_commands=0;
   930     for $command (keys %CommandsFrequency){
   931         $total_commands += $CommandsFrequency{$command};
   932     }
   933     if ($total_commands) {
   934         for $command (reverse sort {$CommandsFrequency{$a} <=> $CommandsFrequency{$b}} keys %CommandsFrequency){
   935             my $command_html;
   936             my $percentage = sprintf "%5.2f",$CommandsFrequency{$command}*100/$total_commands;
   937             if ($percentage < 0.5) {
   938                 my $hint = make_comment($command);
   939                 $command_html = "$command";
   940                 $command_html = "<span title='$hint' class='with_hint'>$command_html</span>" if $hint;
   941                 $command_html = "<span class='without_hint'>$command_html</span>" if not $hint;
   942                 my $command_html = "<tt>$command_html</tt>";
   943                 $Stat{RareCommands} .= $command_html."<sub><font size='-2'>".$CommandsFrequency{$command}."</font></sub> , ";
   944             }
   945             else {
   946                 my $hint = make_comment($command);
   947                 $command_html = "$command";
   948                 $command_html = "<span title='$hint' class='with_hint'>$command_html</span>" if $hint;
   949                 $command_html = "<span class='without_hint'>$command_html</span>" if not $hint;
   950                 my $command_html = "<tt>$command_html</tt>";
   951                 $percentage = sprintf "%5.2f",$percentage;
   952                 $Stat{CommandsFrequency} .= "<tr><td>".$command_html."</td><td>".$CommandsFrequency{$command}."</td>".
   953                     "<td>|".("="x int($CommandsFrequency{$command}*100/$total_commands))."| $percentage%</td></tr>";
   954             }
   955         }
   956         $Stat{CommandsFrequency} = "<table>".$Stat{CommandsFrequency}."</table>";
   957         $Stat{RareCommands} =~ s/, $// if $Stat{RareCommands};
   958     }
   960     my $result = q();
   961     for my $stat (@StatOrder) {
   962         next unless $Stat{"$stat"};
   963         $result .= "<tr valign='top'><td width='300'>".$StatNames{"$stat"}."</td><td>".$Stat{"$stat"}."</td></tr>"
   964     }
   965     $result  = "<table>$result</table>"
   966              . "<font size='-2'>____<br/>*) Интервалы неактивности длительностью "
   967              .  ($Config{stat_inactivity_interval}/60)
   968              . " минут и более не учитываются</font></br>";
   970     return $result;
   971 }
   974 sub collapse_list($)
   975 {
   976     my $res = "";
   977     for my $elem (@{$_[0]}) {
   978         if (ref $elem eq "ARRAY") {
   979             $res .= "<ul>".collapse_list($elem)."</ul>";
   980         }
   981         else
   982         {
   983             $res .= "<li>".$elem."</li>";
   984         }
   985     }
   986     return $res;
   987 }
   992 sub init_variables
   993 {
   994 $Html_Help = <<HELP;
   995     Для того чтобы использовать LiLaLo, не нужно знать ничего особенного:
   996     всё происходит само собой.
   997     Однако, чтобы ведение и последующее использование журналов
   998     было как можно более эффективным, желательно иметь в виду следующее:
   999     <ol>
  1000     <li><p> 
  1001     В журнал автоматически попадают все команды, данные в любом терминале системы.
  1002     </p></li>
  1003     <li><p>
  1004     Для того чтобы убедиться, что журнал на текущем терминале ведётся, 
  1005     и команды записываются, дайте команду w.
  1006     В поле WHAT, соответствующем текущему терминалу, 
  1007     должна быть указана программа script.
  1008     </p></li>
  1009     <li><p>
  1010     Команды, при наборе которых были допущены синтаксические ошибки, 
  1011     выводятся перечёркнутым текстом:
  1012 <table>
  1013 <tr class='command'>
  1014 <td class='script'>
  1015 <pre class='mistyped_cline'>
  1016 \$ l s-l</pre>
  1017 <pre class='mistyped_output'>bash: l: command not found
  1018 </pre>
  1019 </td>
  1020 </tr>
  1021 </table>
  1022 <br/>
  1023     </p></li>
  1024     <li><p>
  1025     Если код завершения команды равен нулю, 
  1026     команда была выполнена без ошибок.
  1027     Команды, код завершения которых отличен от нуля, выделяются цветом.
  1028 <table>
  1029 <tr class='command'>
  1030 <td class='script'>
  1031 <pre class='wrong_cline'>
  1032 \$ test 5 -lt 4</pre>
  1033 </pre>
  1034 </td>
  1035 </tr>
  1036 </table>
  1037     Обратите внимание на то, что код завершения команды может быть отличен от нуля
  1038     не только в тех случаях, когда команда была выполнена с ошибкой.
  1039     Многие команды используют код завершения, например, для того чтобы показать результаты проверки
  1040 <br/>
  1041     </p></li>
  1042     <li><p>
  1043     Команды, ход выполнения которых был прерван пользователем, выделяются цветом.
  1044 <table>
  1045 <tr class='command'>
  1046 <td class='script'>
  1047 <pre class='interrupted_cline'>
  1048 \$ find / -name abc</pre>
  1049 <pre class='interrupted_output'>find: /home/devi-orig/.gnome2: Keine Berechtigung
  1050 find: /home/devi-orig/.gnome2_private: Keine Berechtigung
  1051 find: /home/devi-orig/.nautilus/metafiles: Keine Berechtigung
  1052 find: /home/devi-orig/.metacity: Keine Berechtigung
  1053 find: /home/devi-orig/.inkscape: Keine Berechtigung
  1054 ^C
  1055 </pre>
  1056 </td>
  1057 </tr>
  1058 </table>
  1059 <br/>
  1060     </p></li>
  1061     <li><p>
  1062     Команды, выполненные с привилегиями суперпользователя,
  1063     выделяются слева красной чертой.
  1064 <table>
  1065 <tr class='command'>
  1066 <td class='script'>
  1067 <pre class='_root_cline'>
  1068 # id</pre>
  1069 <pre class='_root_output'>
  1070 uid=0(root) gid=0(root) Gruppen=0(root)
  1071 </pre>
  1072 </td>
  1073 </tr>
  1074 </table>
  1075     <br/>
  1076     </p></li>
  1077     <li><p>
  1078     Изменения, внесённые в текстовый файл с помощью редактора, 
  1079     запоминаются и показываются в журнале в формате ed.
  1080     Строки, начинающиеся символом "<", удалены, а строки,
  1081     начинающиеся символом ">" -- добавлены.
  1082 <table>
  1083 <tr class='command'>
  1084 <td class='script'>
  1085 <pre class='cline'>
  1086 \$ vi ~/.bashrc</pre>
  1087 <table><tr><td width='5'/><td class='diff'><pre>2a3,5
  1088 >    if [ -f /usr/local/etc/bash_completion ]; then
  1089 >         . /usr/local/etc/bash_completion
  1090 >        fi
  1091 </pre></td></tr></table></td>
  1092 </tr>
  1093 </table>
  1094     <br/>
  1095     </p></li>
  1096     <li><p>
  1097     Для того чтобы изменить файл в соответствии с показанными в диффшоте
  1098     изменениями, можно воспользоваться командой patch.
  1099     Нужно скопировать изменения, запустить программу patch, указав в
  1100     качестве её аргумента файл, к которому применяются изменения,
  1101     и всавить скопированный текст:
  1102 <table>
  1103 <tr class='command'>
  1104 <td class='script'>
  1105 <pre class='cline'>
  1106 \$ patch ~/.bashrc</pre>
  1107 </td>
  1108 </tr>
  1109 </table>
  1110     В данном случае изменения применяются к файлу ~/.bashrc
  1111     </p></li>
  1112     <li><p>
  1113     Для того чтобы получить краткую справочную информацию о команде, 
  1114     нужно подвести к ней мышь. Во всплывающей подсказке появится краткое
  1115     описание команды.
  1116     </p>
  1117     <p>
  1118     Если справочная информация о команде есть, 
  1119     команда выделяется голубым фоном, например: <span class="with_hint" title="главный текстовый редактор Unix">vi</span>.
  1120     Если справочная информация отсутствует,
  1121     команда выделяется розовым фоном, например: <span class="without_hint">notepad.exe</span>.
  1122     Справочная информация может отсутствовать в том случае, 
  1123     если (1) команда введена неверно; (2) если распознавание команды LiLaLo выполнено неверно;
  1124     (3) если информация о команде неизвестна LiLaLo.
  1125     Последнее возможно для редких команд.
  1126     </p></li>
  1127     <li><p>
  1128     Большие, в особенности многострочные, всплывающие подсказки лучше 
  1129     всего показываются браузерами KDE Konqueror, Apple Safari и Microsoft Internet Explorer.
  1130     В браузерах Mozilla и Firefox они отображаются не полностью, 
  1131     а вместо перевода строки выводится специальный символ.
  1132     </p></li>
  1133     <li><p>
  1134     Время ввода команды, показанное в журнале, соответствует времени 
  1135     <i>начала ввода командной строки</i>, которое равно тому моменту, 
  1136     когда на терминале появилось приглашение интерпретатора
  1137     </p></li>
  1138     <li><p>
  1139     Имя терминала, на котором была введена команда, показано в специальном блоке.
  1140     Этот блок показывается только в том случае, если терминал
  1141     текущей команды отличается от терминала предыдущей.
  1142     </p></li>
  1143     <li><p>
  1144     Вывод не интересующих вас в настоящий момент элементов журнала,
  1145     таких как время, имя терминала и других, можно отключить.
  1146     Для этого нужно воспользоваться <a href='#visibility_form'>формой управления журналом</a>
  1147     вверху страницы.
  1148     </p></li>
  1149     <li><p>
  1150     Небольшие комментарии к командам можно вставлять прямо из командной строки.
  1151     Комментарий вводится прямо в командную строку, после символов #^ или #v.
  1152     Символы ^ и v показывают направление выбора команды, к которой относится комментарий:
  1153     ^ - к предыдущей, v - к следующей.
  1154     Например, если в командной строке было введено:
  1155 <pre class='cline'>
  1156 \$ whoami
  1157 </pre>
  1158 <pre class='output'>
  1159 user
  1160 </pre>
  1161 <pre class='cline'>
  1162 \$ #^ Интересно, кто я?
  1163 </pre>
  1164     в журнале это будет выглядеть так:
  1166 <pre class='cline'>
  1167 \$ whoami
  1168 </pre>
  1169 <pre class='output'>
  1170 user
  1171 </pre>
  1172 <table class='note'><tr><td width='100%' class='note_text'>
  1173 <tr> <td> Интересно, кто я?<br/> </td></tr></table> 
  1174     </p></li>
  1175     <li><p>
  1176     Если комментарий содержит несколько строк,
  1177     его можно вставить в журнал следующим образом:
  1178 <pre class='cline'>
  1179 \$ whoami
  1180 </pre>
  1181 <pre class='output'>
  1182 user
  1183 </pre>
  1184 <pre class='cline'>
  1185 \$ cat > /dev/null #^ Интересно, кто я?
  1186 </pre>
  1187 <pre class='output'>
  1188 Программа whoami выводит имя пользователя, под которым 
  1189 мы зарегистрировались в системе.
  1190 -
  1191 Она не может ответить на вопрос о нашем назначении 
  1192 в этом мире.
  1193 </pre>
  1194     В журнале это будет выглядеть так:
  1195 <table>
  1196 <tr class='command'>
  1197 <td class='script'>
  1198 <pre class='cline'>
  1199 \$ whoami</pre>
  1200 <pre class='output'>user
  1201 </pre>
  1202 <table class='note'><tr><td class='note_title'>Интересно, кто я?</td></tr><tr><td width='100%' class='note_text'>
  1203 Программа whoami выводит имя пользователя, под которым<br/>
  1204 мы зарегистрировались в системе.<br/>
  1205 <br/>
  1206 Она не может ответить на вопрос о нашем назначении<br/>
  1207 в этом мире.<br/>
  1208 </td></tr></table>
  1209 </td>
  1210 </tr>
  1211 </table>
  1212     Для разделения нескольких абзацев между собой
  1213     используйте символ "-", один в строке.
  1214     <br/>
  1215 </p></li>
  1216     <li><p>
  1217     Комментарии, не относящиеся непосредственно ни к какой из команд, 
  1218     добавляются точно таким же способом, только вместо симолов #^ или #v 
  1219     нужно использовать символы #=
  1220     </p></li>
  1221 </ol>
  1222 HELP
  1224 $Html_About = <<ABOUT;
  1225     <p>
  1226     LiLaLo (L3) расшифровывается как Live Lab Log.<br/>
  1227     Программа разработана для повышения эффективности обучения Unix/Linux-системам.<br/>
  1228     (c) Игорь Чубин, 2004-2005<br/>
  1229     </p>
  1230 ABOUT
  1231 $Html_About.='$Id$ </p>';
  1233 $Html_JavaScript = <<JS;
  1234     function getElementsByClassName(Class_Name)
  1235     {
  1236         var Result=new Array();
  1237         var All_Elements=document.all || document.getElementsByTagName('*');
  1238         for (i=0; i<All_Elements.length; i++)
  1239             if (All_Elements[i].className==Class_Name)
  1240         Result.push(All_Elements[i]);
  1241         return Result;
  1242     }
  1243     function ShowHide (name)
  1244     {
  1245         elements=getElementsByClassName(name);
  1246         for(i=0; i<elements.length; i++)
  1247             if (elements[i].style.display == "none")
  1248                 elements[i].style.display = "";
  1249             else
  1250                 elements[i].style.display = "none";
  1251             //if (elements[i].style.visibility == "hidden")
  1252             //  elements[i].style.visibility = "visible";
  1253             //else
  1254             //  elements[i].style.visibility = "hidden";
  1255     }
  1256     function filter_by_output(text)
  1257     {
  1259         var jjj=0;
  1261         elements=getElementsByClassName('command');
  1262         for(i=0; i<elements.length; i++) {
  1263             subelems = elements[i].getElementsByTagName('pre');
  1264             for(j=0; j<subelems.length; j++) {
  1265                 if (subelems[j].className = 'output') {
  1266                     var str = new String(subelems[j].nodeValue);
  1267                     if (jjj != 1) { 
  1268                         alert(str);
  1269                         jjj=1;
  1270                     }
  1271                     if (str.indexOf(text) >0) 
  1272                         subelems[j].style.display = "none";
  1273                     else
  1274                         subelems[j].style.display = "";
  1276                 }
  1278             }
  1279         }       
  1281     }
  1282 JS
  1284 %Search_Machines = (
  1285         "google" =>     {   "query" =>  "http://www.google.com/search?q=" ,
  1286                     "icon"  =>  "$Config{frontend_google_ico}" },
  1287         "freebsd" =>    {   "query" =>  "http://www.freebsd.org/cgi/man.cgi?query=",
  1288                     "icon"  =>  "$Config{frontend_freebsd_ico}" },
  1289         "linux"  =>     {   "query" =>  "http://man.he.net/?topic=",
  1290                     "icon"  =>  "$Config{frontend_linux_ico}"},
  1291         "opennet"  =>   {   "query" =>  "http://www.opennet.ru/search.shtml?words=",
  1292                     "icon"  =>  "$Config{frontend_opennet_ico}"},
  1293         "local" =>  {   "query" =>  "http://www.freebsd.org/cgi/man.cgi?query=",
  1294                     "icon"  =>  "$Config{frontend_local_ico}" },
  1296     );
  1298 %Elements_Visibility = (
  1299         "note"      =>  "замечания",
  1300         "diff"      =>  "редактор",
  1301         "time"      =>  "время",
  1302         "ttychange"     =>  "терминал",
  1303         "wrong_output wrong_cline wrong_root_output wrong_root_cline" 
  1304                 =>  "команды с ошибками",
  1305         "interrupted_output interrupted_cline interrupted_root_output interrupted_root_cline" 
  1306                 =>  "прерванные команды",
  1307         "tab_completion_output tab_completion_cline"    
  1308                 =>  "продолжение с помощью tab"
  1309 );
  1311 @Day_Name      = qw/ Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота /;
  1312 @Month_Name    = qw/ Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь /;
  1313 @Of_Month_Name = qw/ Января Февраля Марта Апреля Мая Июня Июля Августа Сентября Октября Ноября Декабря /;
  1314 }
  1319 # Временно удалённый код
  1320 # Возможно, он не понадобится уже никогда
  1323 sub search_by
  1324 {
  1325     my $sm = shift;
  1326     my $topic = shift;
  1327     $topic =~ s/ /+/;
  1329     return "<a href='". $Search_Machines{$sm}->{"query"}."$topic'><img width='16' height='16' src='".
  1330                 $Search_Machines{$sm}->{"icon"}."' border='0'/></a>";
  1331 }
