lilalo

view l3-frontend @ 69:1e1422588716

l3-agent, l3-frontend:

1)
Добавилась поддержка автоматического выкусывания файлов.
По-видимому нужно сделать чтобы автоматически вы журнале
показывались только самые вкусные файлы,
отмеченные знаком
#!
Остальные же чтобы можно было посмотреть по ссылке


2)
Форма управления видимостью элементов
находится в правом верхнем углу экрана,
и не прокручивается по мере прокрутки журнала.
Надо ещё будет сделать чтобы можно было её прятать.

lm:
Добавил
lm show email
author devi
date Tue Jan 31 20:18:54 2006 +0200 (2006-01-31)
parents 8c3d80c4891b
children 35e0d61c820d
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 our %Files;
17 # vvv Инициализация переменных выполняется процедурой init_variables
18 our @Day_Name;
19 our @Month_Name;
20 our @Of_Month_Name;
21 our %Search_Machines;
22 our %Elements_Visibility;
23 # ^^^
25 our %Stat;
26 our %CommandsFDistribution; # Сколько раз в журнале встречается какая команда
27 our $table_number=1;
29 my %mywi_cache_for; # Кэш для экономии обращений к mywi
31 sub make_comment;
32 sub make_new_entries_table;
33 sub load_command_lines_from_xml;
34 sub load_sessions_from_xml;
35 sub sort_command_lines;
36 sub process_command_lines;
37 sub init_variables;
38 sub main;
39 sub collapse_list($);
41 sub print_all;
42 sub print_command_lines;
43 sub print_files;
44 sub print_stat;
45 sub print_header;
46 sub print_footer;
48 main();
50 sub main
51 {
52 $| = 1;
54 init_variables();
55 init_config();
56 $Config{frontend_ico_path}=$Config{frontend_css};
57 $Config{frontend_ico_path}=~s@/[^/]*$@@;
59 open_mywi_socket();
60 load_command_lines_from_xml($Config{"backend_datafile"});
61 load_sessions_from_xml($Config{"backend_datafile"});
62 sort_command_lines;
63 process_command_lines;
64 print_all($Config{"output"});
65 close_mywi_socket;
66 }
68 # extract_from_cline
70 # In: $what = commands | args
71 # Out: return ссылка на хэш, содержащий результаты разбора
72 # команда => позиция
74 # Разобрать командную строку $_[1] и возвратить хэш, содержащий
75 # номер первого появление команды в строке:
76 # команда => первая позиция
77 sub extract_from_cline
78 {
79 my $what = $_[0];
80 my $cline = $_[1];
81 my @lists = split /\;/, $cline;
84 my @command_lines = ();
85 for my $command_list (@lists) {
86 push(@command_lines, split(/\|/, $command_list));
87 }
89 my %position_of_command;
90 my %position_of_arg;
91 my $i=0;
92 for my $command_line (@command_lines) {
93 $command_line =~ s@^\s*@@;
94 $command_line =~ /\s*(\S+)\s*(.*)/;
95 if ($1 && $1 eq "sudo" ) {
96 $position_of_command{"$1"}=$i++;
97 $command_line =~ s/\s*sudo\s+//;
98 }
99 if ($command_line !~ m@^\s*\S*/etc/@) {
100 $command_line =~ s@^\s*\S+/@@;
101 }
103 $command_line =~ /\s*(\S+)\s*(.*)/;
104 my $command = $1;
105 my $args = $2;
106 if ($command && !defined $position_of_command{"$command"}) {
107 $position_of_command{"$command"}=$i++;
108 };
109 if ($args) {
110 my @args = split (/\s+/, $args);
111 for my $a (@args) {
112 $position_of_arg{"$a"}=$i++
113 if !defined $position_of_arg{"$a"};
114 };
115 }
116 }
118 if ($what eq "commands") {
119 return \%position_of_command;
120 } else {
121 return \%position_of_arg;
122 }
124 }
129 #
130 # Подпрограммы для работы с mywi
131 #
133 sub open_mywi_socket
134 {
135 $Mywi_Socket = IO::Socket::INET->new(
136 PeerAddr => $Config{mywi_server},
137 PeerPort => $Config{mywi_port},
138 Proto => "tcp",
139 Type => SOCK_STREAM);
140 }
142 sub close_mywi_socket
143 {
144 close ($Mywi_Socket) if $Mywi_Socket ;
145 }
148 sub mywi_client
149 {
150 my $query = $_[0];
151 my $mywi;
153 open_mywi_socket;
154 if ($Mywi_Socket) {
155 local $| = 1;
156 local $/ = "";
157 print $Mywi_Socket $query."\n";
158 $mywi = <$Mywi_Socket>;
159 $mywi = "" if $mywi =~ /nothing app/;
160 }
161 close_mywi_socket;
162 return $mywi;
163 }
165 sub make_comment
166 {
167 my $cline = $_[0];
168 #my $files = $_[1];
170 my @comments;
171 my @commands = keys %{extract_from_cline("commands", $cline)};
172 my @args = keys %{extract_from_cline("args", $cline)};
173 return if (!@commands && !@args);
174 #return "commands=".join(" ",@commands)."; files=".join(" ",@files);
176 # Commands
177 for my $command (@commands) {
178 $command =~ s/'//g;
179 $CommandsFDistribution{$command}++;
180 if (!$Commands_Description{$command}) {
181 $mywi_cache_for{$command} ||= mywi_client ($command) || "";
182 my $mywi = join ("\n", grep(/\([18]|sh|script\)/, split(/\n/, $mywi_cache_for{$command})));
183 $mywi =~ s/\s+/ /;
184 if ($mywi !~ /^\s*$/) {
185 $Commands_Description{$command} = $mywi;
186 }
187 else {
188 next;
189 }
190 }
192 push @comments, $Commands_Description{$command};
193 }
194 return join("&#10;\n", @comments);
196 # Files
197 for my $arg (@args) {
198 $arg =~ s/'//g;
199 if (!$Args_Description{$arg}) {
200 my $mywi;
201 $mywi = mywi_client ($arg);
202 $mywi = join ("\n", grep(/\([5]\)/, split(/\n/, $mywi)));
203 $mywi =~ s/\s+/ /;
204 if ($mywi !~ /^\s*$/) {
205 $Args_Description{$arg} = $mywi;
206 }
207 else {
208 next;
209 }
210 }
212 push @comments, $Args_Description{$arg};
213 }
215 }
217 =cut
218 Процедура load_command_lines_from_xml выполняет загрузку разобранного lab-скрипта
219 из XML-документа в переменную @Command_Lines
221 # In: $datafile имя файла
222 # Out: @CommandLines загруженные командные строки
224 Предупреждение!
225 Процедура не в состоянии обрабатывать XML-документ любой структуры.
226 В действительности файл cache из которого загружаются данные
227 просто напоминает XML с виду.
228 =cut
229 sub load_command_lines_from_xml
230 {
231 my $datafile = $_[0];
233 open (CLASS, $datafile)
234 or die "Can't open file of the class ",$datafile,"\n";
235 local $/;
236 $data = <CLASS>;
237 close(CLASS);
239 for $command ($data =~ m@<command>(.*?)</command>@sg) {
240 my %cl;
241 while ($command =~ m@<([^>]*?)>(.*?)</\1>@sg) {
242 $cl{$1} = $2;
243 }
244 push @Command_Lines, \%cl;
245 }
246 }
248 sub load_sessions_from_xml
249 {
250 my $datafile = $_[0];
252 open (CLASS, $datafile)
253 or die "Can't open file of the class ",$datafile,"\n";
254 local $/;
255 my $data = <CLASS>;
256 close(CLASS);
258 for my $session ($data =~ m@<session>(.*?)</session>@sg) {
259 my %session;
260 while ($session =~ m@<([^>]*?)>(.*?)</\1>@sg) {
261 $session{$1} = $2;
262 }
263 $Sessions{$session{local_session_id}} = \%session;
264 }
265 }
268 # sort_command_lines
269 # In: @Command_Lines
270 # Out: @Command_Lies_Index
272 sub sort_command_lines
273 {
275 my @index;
276 for (my $i=0;$i<=$#Command_Lines;$i++) {
277 $index[$i]=$i;
278 }
280 @Command_Lines_Index = sort {
281 $Command_Lines[$index[$a]]->{"time"} <=> $Command_Lines[$index[$b]]->{"time"}
282 } @index;
284 }
286 ##################
287 # process_command_lines
288 #
289 # Обрабатываются командные строки @Command_Lines
290 # Для каждой строки определяется:
291 # class класс
292 # note комментарий
293 #
294 # In: @Command_Lines_Index
295 # In-Out: @Command_Lines
297 sub process_command_lines
298 {
299 for my $i (@Command_Lines_Index) {
300 my $cl = \$Command_Lines[$i];
302 next if !$cl;
304 $$cl->{err} ||=0;
306 # Класс команды
308 $$cl->{"class"} = $$cl->{"err"} eq 130 ? "interrupted"
309 : $$cl->{"err"} eq 127 ? "mistyped"
310 : $$cl->{"err"} ? "wrong"
311 : "normal";
313 if ($$cl->{"cline"} =~ /[^|`]\s*sudo/
314 || $$cl->{"uid"} eq 0) {
315 $$cl->{"class"}.="_root";
316 }
319 #Обработка пометок
320 # Если несколько пометок (notes) идут подряд,
321 # они все объединяются
323 if ($$cl->{cline}=~ m@cat[^#]*#([\^=v])\s*(.*)@) {
325 my $note_operator = $1;
326 my $note_title = $2;
328 if ($note_operator eq "=") {
329 $$cl->{"class"} = "note";
330 $$cl->{"note"} = $$cl->{"output"};
331 $$cl->{"note_title"} = $2;
332 }
333 else {
334 my $j = $i;
335 if ($note_operator eq "^") {
336 $j--;
337 $j-- while ($j >=0 && (!$Command_Lines[$j] || $Command_Lines[$j]->{tty} ne $$cl->{tty}));
338 }
339 elsif ($note_operator eq "v") {
340 $j++;
341 $j++ while ($j <= @Command_Lines && (!$Command_Lines[$j] || $Command_Lines[$j]->{tty} ne $$cl->{tty}));
342 }
343 $Command_Lines[$j]->{note_title}=$note_title;
344 $Command_Lines[$j]->{note}.=$$cl->{output};
345 $$cl=0;
346 }
347 }
348 elsif ($$cl->{cline}=~ /#([\^=v])(.*)/) {
350 my $note_operator = $1;
351 my $note_text = $2;
353 if ($note_operator eq "=") {
354 $$cl->{"class"} = "note";
355 $$cl->{"note"} = $note_text;
356 }
357 else {
358 my $j=$i;
359 if ($note_operator eq "^") {
360 $j--;
361 $j-- while ($j >=0 && (!$Command_Lines[$j] || $Command_Lines[$j]->{tty} ne $$cl->{tty}));
362 }
363 elsif ($note_operator eq "v") {
364 $j++;
365 $j++ while ($j <= @Command_Lines && $Command_Lines[$j]->{tty} ne $$cl->{tty} || !$Command_Lines[$j]);
366 }
367 $Command_Lines[$j]->{note}.="$note_text\n";
368 $$cl=0;
369 }
370 }
371 }
373 }
376 =cut
377 Процедура print_command_lines выводит HTML-представление
378 разобранного lab-скрипта.
380 Разобранный lab-скрипт должен находиться в массиве @Command_Lines
381 =cut
383 sub print_command_lines
384 {
386 my @toc; # Оглавление
387 my $note_number=0;
389 my $result = q();
390 my $this_day_resut = q();
392 my $cl;
393 my $last_tty="";
394 my $last_day=q();
395 my $last_wday=q();
396 my $in_range=0;
398 my $current_command=0;
400 my @known_commands;
402 my %filter;
404 if ($Config{filter}) {
405 # Инициализация фильтра
406 for (split /&/,$Config{filter}) {
407 my ($var, $val) = split /=/;
408 $filter{$var} = $val || "";
409 }
410 }
412 #$result = "Filter=".$Config{filter}."\n";
414 $Stat{LastCommand} ||= 0;
415 $Stat{TotalCommands} ||= 0;
416 $Stat{ErrorCommands} ||= 0;
417 $Stat{MistypedCommands} ||= 0;
419 my %new_entries_of = (
420 "1 1" => "программы пользователя",
421 "2 8" => "программы администратора",
422 "3 sh" => "команды интерпретатора",
423 "4 script"=> "скрипты",
424 );
426 COMMAND_LINE:
427 for my $k (@Command_Lines_Index) {
429 my $cl=$Command_Lines[$Command_Lines_Index[$current_command++]];
430 next unless $cl;
432 # Пропускаем команды, с одинаковым временем
433 # Это не совсем правильно.
434 # Возможно, что это команды, набираемые с помощью <completion>
435 # или запомненные с помощью <ctrl-c>
437 next if $Stat{LastCommand} == $cl->{time};
439 # Пропускаем строки, которые противоречат фильтру
440 # Если у нас недостаточно информации о том, подходит строка под фильтр или нет,
441 # мы её выводим
443 #$result .= "before<br/>";
444 for my $filter_key (keys %filter) {
445 #$result .= "undefined local session id<br/>\n" if !defined($cl->{local_session_id});
446 #$result .= "undefined filter key $filter_key <br/>\n" if !defined($Sessions{$cl->{local_session_id}}->{$filter_key});
447 #$result .= $Sessions{$cl->{local_session_id}}->{$filter_key}." != ".$filter{$filter_key};
448 next COMMAND_LINE if
449 defined($cl->{local_session_id})
450 && defined($Sessions{$cl->{local_session_id}}->{$filter_key})
451 && $Sessions{$cl->{local_session_id}}->{$filter_key} ne $filter{$filter_key};
452 }
454 # Набираем статистику
455 # Хэш %Stat
457 $Stat{FirstCommand} = $cl->{time} unless $Stat{FirstCommand};
458 if ($cl->{time} - $Stat{LastCommand} < $Config{stat_inactivity_interval}) {
459 $Stat{TotalTime} += $cl->{time} - $Stat{LastCommand}
460 }
461 my $seconds_since_last_command = $cl->{time} - $Stat{LastCommand};
462 $Stat{LastCommand} = $cl->{time};
463 $Stat{TotalCommands}++;
466 # Пропускаем строки, выходящие за границу "signature",
467 # при условии, что границы указаны
468 # Пропускаем неправильные/прерванные/другие команды
469 if ($Config{"from"} && $cl->{"cline"} =~ /$Config{"signature"}\s*$Config{"from"}/) {
470 $in_range=1;
471 next;
472 }
473 if ($Config{"to"} && $cl->{"cline"} =~ /$Config{"signature"}\s*$Config{"to"}/) {
474 $in_range=0;
475 next;
476 }
477 next if ($Config{"from"} && $Config{"to"} && !$in_range)
478 || ($Config{"skip_empty"} =~ /^y/i && $cl->{"cline"} =~ /^\s*$/ )
479 || ($Config{"skip_wrong"} =~ /^y/i && $cl->{"err"} != 0)
480 || ($Config{"skip_interrupted"} =~ /^y/i && $cl->{"err"} == 130);
482 if ($cl->{class} eq "note") {
483 my $note = $cl->{note};
484 $note = join ("\n", map ("<p>$_</p>", split (/-\n/, $note)));
485 $note =~ s@(http:[a-zA-Z.0-9/?\_%-]*)@<a href='$1'>$1</a>@g;
486 $note =~ s@(www\.[a-zA-Z.0-9/?\_%-]*)@<a href='$1'>$1</a>@g;
487 $this_day_result .= "<tr><td colspan='6'>"
488 . "<h4 id='note$note_number'>".$cl->{note_title}."</h4>" if $cl->{note_title}
489 . "".$note."<p/><p/></td></tr>";
491 if ($cl->{note_title}) {
492 push @{$toc[@toc]},"<a href='#note$note_number'>".$cl->{note_title}."</a>";
493 $note_number++;
494 }
495 next;
496 }
499 my $output="";
500 # Выводим <head_lines> верхних строк
501 # и <tail_lines> нижних строк,
502 # если эти параметры существуют
504 if ($cl->{"last_command"} eq "cat" && !$cl->{"err"} && !($cl->{"cline"} =~ /</)) {
505 my $filename = $cl->{"cline"};
506 $filename =~ s/.*\s+(\S+)\s*$/$1/;
507 $Files{$filename} = $cl->{"output"};
508 }
509 my @lines = split '\n', $cl->{"output"};
510 if ((
511 $Config{"head_lines"}
512 || $Config{"tail_lines"}
513 )
514 && $#lines > $Config{"head_lines"} + $Config{"tail_lines"} ) {
516 for (my $i=0; $i<= $#lines && $i < $Config{"head_lines"}; $i++) {
517 $output .= $lines[$i]."\n";
518 }
519 $output .= $Config{"skip_text"}."\n";
521 my $start_line=$#lines-$Config{"tail_lines"}+1;
522 for ($i=$start_line; $i<= $#lines; $i++) {
523 $output .= $lines[$i]."\n";
524 }
525 }
526 else {
527 $ output .= $cl->{"output"};
528 }
530 #
531 ##
532 ## Начинается собственно вывод
533 ##
534 #
536 my ($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst) = localtime($cl->{time});
538 # Добавляем спереди 0 для удобочитаемости
539 $min = "0".$min if $min =~ /^.$/;
540 $hour = "0".$hour if $hour =~ /^.$/;
541 $sec = "0".$sec if $sec =~ /^.$/;
543 $class=$cl->{"class"};
544 $Stat{ErrorCommands}++ if $class =~ /wrong/;
545 $Stat{MistypedCommands}++ if $class =~ /mistype/;
548 # DAY CHANGE
549 if ( $last_day ne $day) {
550 if ($last_day) {
552 # Вычисляем разность множеств.
553 # Что-то вроде этого, если бы так можно было писать:
554 # @new_commands = keys %CommandsFDistribution - @known_commands;
557 $result .= "<h3 id='day$last_day'>".$Day_Name[$last_wday]."</h3>";
561 for my $entry_class (sort keys %new_entries_of) {
562 my $new_commands_section = make_new_entries_table($entry_class=~/[0-9]+\s+(.*)/, \@known_commands);
564 my $table_caption = "Таблица ".$table_number++.". ".$Day_Name[$last_wday].". Новые ".$new_entries_of{$entry_class};
565 if ($new_commands_section) {
566 $result .= "<table class='new_commands_table' width='700'>"
567 . "<tr class='new_commands_caption'><td colspan='2' align='right'>$table_caption</td></tr>"
568 . "<tr class='new_commands_header'><td width=100>Команда</td><td width=600>Описание</td></tr>"
569 . $new_commands_section
570 . "</table>"
571 }
573 }
574 @known_commands = keys %CommandsFDistribution;
575 $result .= "<table width='100%'>\n";
576 $result .= $this_day_result;
577 $result .= "</table>";
578 }
580 push @toc, "<a href='#day$day'>".$Day_Name[$wday]."</a>\n";
581 $last_day=$day;
582 $last_wday=$wday;
583 $this_day_result = q();
584 }
585 elsif ($seconds_since_last_command > 600) {
586 my $height = $seconds_since_last_command > 1200 ? 100: 60;
587 my $minutes_passed = int($seconds_since_last_command/60);
590 my $passed_word = $minutes_passed % 10 == 1 ? "прошла"
591 : "прошло";
592 my $minutes_word = $minutes_passed % 100 > 10
593 && $minutes_passed % 100 < 20 ? "минут" :
594 $minutes_passed % 10 == 1 ? "минута":
595 $minutes_passed % 10 == 0 ? "минут" :
596 $minutes_passed % 10 > 4 ? "минут" :
597 "минуты";
599 $this_day_result .= "<tr height='60'>"
600 . "<td colspan='5' height='$height'>"
601 . "<font size='-1'>"
602 . $passed_word." ".$minutes_passed." ".$minutes_word
603 . "</font>"
604 . "</td></tr>\n";
605 }
607 $this_day_result .= "<tr class='command'>\n";
610 # CONSOLE CHANGE
611 if ( $last_tty ne $cl->{"tty"}) {
612 my $tty = $cl->{"tty"};
613 $this_day_result .= "<td colspan='6'>"
614 ."<table><tr><td class='ttychange' width='140' align='center'>"
615 . $tty
616 ."</td></tr></table>"
617 ."</td></tr><tr>";
618 $last_tty=$cl->{"tty"};
619 }
621 # TIME
622 $this_day_result .= $Config{"show_time"} =~ /^y/i
623 ? "<td width='100' valign='top' class='time' width='$Config{time_width}'>$hour:$min:$sec</td>"
624 : "<td width='0'/>";
626 # CLASS
627 # if ($cl->{"err"}) {
628 # $this_day_result .= "<td width='6' valign='top'>"
629 # . "<table><tr><td width='6' height='6' class='err_box'>"
630 # . "E"
631 # . "</td></tr></table>"
632 # . "</td>";
633 # }
634 # else {
635 # $this_day_result .= "<td width='10' valign='top'>"
636 # . " "
637 # . "</td>";
638 # }
640 # COMMAND
641 my $hint = make_comment($cl->{"cline"});
643 my $cline;
644 $cline = $cl->{"prompt"}.$cl->{"cline"};
645 $cline =~ s/\n//;
647 $cline = "<span title='$hint' class='with_hint'>$cline</span>" if $hint;
648 $cline = "<span class='without_hint'>$cline</span>" if !$hint;
650 $this_day_result .= "<td class='script'>\n";
651 $this_day_result .= "<pre class='${class}_cline'>\n" . $cline ;
652 $this_day_result .= "<span title='Код завершения ".$cl->{"err"}."'> <img src='".$Config{frontend_ico_path}."/error.png'/></span>" if $cl->{"err"};
653 $this_day_result .= "</pre>\n";
655 # OUTPUT
656 my $last_command = $cl->{"last_command"};
657 if (!(
658 $Config{"suppress_editors"} =~ /^y/i && grep ($_ eq $last_command, @{$Config{"editors"}}) ||
659 $Config{"suppress_pagers"} =~ /^y/i && grep ($_ eq $last_command, @{$Config{"pagers"}}) ||
660 $Config{"suppress_terminal"}=~ /^y/i && grep ($_ eq $last_command, @{$Config{"terminal"}})
661 )) {
662 $this_day_result .= "<pre class='".$class."_output'>" . $output . "</pre>\n";
663 }
665 # DIFF
666 if ( $Config{"show_diffs"} =~ /^y/i && $cl->{"diff"}) {
667 $this_day_result .= "<table><tr><td width='5'/><td class='diff'><pre>"
668 . $cl->{"diff"}
669 . "</pre></td></tr></table>";
670 }
672 #NOTES
673 if ( $Config{"show_notes"} =~ /^y/i && $cl->{"note"}) {
674 my $note=$cl->{"note"};
675 $note =~ s/\n/<br\/>\n/msg;
676 if (not $note =~ s@(http:[a-zA-Z.0-9/_?%-]*)@<a href='$1'>$1</a>@g) {
677 $note =~ s@(www\.[a-zA-Z.0-9/_?%-]*)@<a href='$1'>$1</a>@g;
678 };
679 # Ширину пока не используем
680 # $this_day_result .= "<table width='$Config{note_width}' class='note'>";
681 $this_day_result .= "<table class='note'>";
682 $this_day_result .= "<tr><td class='note_title'>".$cl->{note_title}."</td></tr>" if $cl->{note_title};
683 $this_day_result .= "<tr><td width='100%' class='note_text'>".$note."</td></tr>";
684 $this_day_result .= "</table>\n";
685 }
687 # COMMENT
688 if ( $Config{"show_comments"} =~ /^y/i) {
689 my $comment = make_comment($cl->{"cline"});
690 if ($comment) {
691 $this_day_result .= "<table width='$Config{comment_width}'><tr><td width='5'/><td>"
692 . "<table class='note' width='100%'>"
693 . $comment
694 . "</table>\n"
695 . "</td></tr></table>";
696 }
697 }
699 # Вывод очередной команды окончен
700 $this_day_result .= "</td>\n";
701 $this_day_result .= "</tr>\n";
702 }
703 last: {
704 $result .= "<h3 id='day$last_day'>".$Day_Name[$last_wday]."</h3>";
706 for my $entry_class (keys %new_entries_of) {
707 my $new_commands_section = make_new_entries_table("$entry_class", \@known_commands);
708 @known_commands = keys %CommandsFDistribution;
710 my $table_caption = "Таблица ".$table_number++.". Новые ".$new_entries_of{$entry_class}. ". ".$Day_Name[$last_wday];
711 if ($new_commands_section) {
712 $result .= "<table class='new_commands_table'>"
713 . "<tr class='new_commands_caption'><td colspan='2' align='right'>$table_caption</td></tr>"
714 . "<tr class='new_commands_header'><td width='200'>Команда</td><td width='600'>Описание</td></tr>"
715 . $new_commands_section
716 . "</table>"
717 ;
718 }
720 }
722 $result .= "<table width='100%'>\n";
723 $result .= $this_day_result;
724 $result .= "</table>";
725 }
727 return ($result, collapse_list (\@toc));
729 }
731 sub make_new_entries_table
732 {
733 my $entries_class = shift;
734 my @known_commands = @{$_[0]};
736 my %count;
737 my @new_commands = ();
738 for my $c (keys %CommandsFDistribution, @known_commands) {
739 $count{$c}++
740 }
741 for my $c (keys %CommandsFDistribution) {
742 push @new_commands, $c if $count{$c} != 2;
743 }
746 my $new_commands_section;
747 if (@new_commands){
748 my $hint;
749 for my $c (reverse sort { $CommandsFDistribution{$a} <=> $CommandsFDistribution{$b} } @new_commands) {
750 $hint = make_comment($c);
751 next unless $hint;
752 my ($command, $hint) = $hint =~ m/(.*?) \s*- \s*(.*)/;
753 next unless $command =~ s/\($entries_class\)//i;
754 $new_commands_section .= "<tr><td valign='top'>$command</td><td>$hint</td></tr>";
755 }
756 }
757 return $new_commands_section;
758 }
761 #############
762 # print_all
763 #
764 #
765 #
766 # In: $_[0] output_filename
767 # Out:
770 sub print_all
771 {
772 my $output_filename=$_[0];
774 my $result;
775 my ($command_lines,$toc) = print_command_lines;
776 my $files_section = print_files;
778 $result = print_header($toc);
779 $result.= "<h2 id='log'>Журнал</h2>" . $command_lines;
780 $result.= "<h2 id='files'>Файлы</h2>" . $files_section if $files_section;
781 $result.= "<h2 id='stat'>Статистика</h2>" . print_stat;
782 $result.= "<h2 id='help'>Справка</h2>" . $Html_Help . "<br/>";
783 $result.= "<h2 id='about'>О программе</h2>". $Html_About. "<br/>";
784 $result.= print_footer;
786 if ($output_filename eq "-") {
787 print $result;
788 }
789 else {
790 open(OUT, ">", $output_filename)
791 or die "Can't open $output_filename for writing\n";
792 print OUT $result;
793 close(OUT);
794 }
795 }
797 #############
798 # print_header
799 #
800 #
801 #
802 # In: $_[0] Содержание
803 # Out: Распечатанный заголовок
805 sub print_header
806 {
807 my $toc = $_[0];
808 my $course_name = $Config{"course-name"};
809 my $course_code = $Config{"course-code"};
810 my $course_date = $Config{"course-date"};
811 my $course_center = $Config{"course-center"};
812 my $course_trainer = $Config{"course-trainer"};
813 my $course_student = $Config{"course-student"};
815 my $title = "Журнал лабораторных работ";
816 $title .= " -- ".$course_student if $course_student;
817 if ($course_date) {
818 $title .= " -- ".$course_date;
819 $title .= $course_code ? "/".$course_code
820 : "";
821 }
822 else {
823 $title .= " -- ".$course_code if $course_code;
824 }
826 # Управляющая форма
827 my $control_form .= "<div class='visibility_form' title='Выберите какие элементы должны быть показаны в журнале'>"
828 . "<span class='header'>Видимые элементы</span>"
829 . "<span class='window_controls'><a href='' onclick='' title='свернуть форму управления'>_</a> <a href='' onclick='' title='закрыть форму управления'>x</a></span>"
830 . "<div><form>\n";
831 for my $element (sort keys %Elements_Visibility)
832 {
833 my ($skip, @e) = split /\s+/, $element;
834 my $showhide = join "", map { "ShowHide('$_');" } @e ;
835 $control_form .= "<div><input type='checkbox' name='$e[0]' onclick=\"$showhide\" checked>".
836 $Elements_Visibility{$element}.
837 "</input></div>";
838 }
839 $control_form .= "</form>\n"
840 . "</div>\n";
842 my $result;
843 $result = <<HEADER;
844 <html>
845 <head>
846 <meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
847 <link rel='stylesheet' href='$Config{frontend_css}' type='text/css'/>
848 <title>$title</title>
849 </head>
850 <body>
851 <script>
852 $Html_JavaScript
853 </script>
855 <!-- vvv Tigra Hints vvv -->
856 <script language="JavaScript" src="/tigra/hints.js"></script>
857 <script language="JavaScript" src="/tigra/hints_cfg.js"></script>
858 <style>
859 /* a class for all Tigra Hints boxes, TD object */
860 .hintsClass
861 {text-align: center; font-family: Verdana, Arial, Helvetica; padding: 0px 0px 0px 0px;}
862 /* this class is used by Tigra Hints wrappers */
863 .row
864 {background: white;}
865 </style>
866 <!-- ^^^ Tigra Hints ^^^ -->
869 <h1 onmouseover="myHint.show('1')" onmouseout="myHint.hide()">Журнал лабораторных работ</h1>
870 HEADER
871 if ( $course_student
872 || $course_trainer
873 || $course_name
874 || $course_code
875 || $course_date
876 || $course_center) {
877 $result .= "<p>";
878 $result .= "Выполнил $course_student<br/>" if $course_student;
879 $result .= "Проверил $course_trainer <br/>" if $course_trainer;
880 $result .= "Курс " if $course_name
881 || $course_code
882 || $course_date;
883 $result .= "$course_name " if $course_name;
884 $result .= "($course_code)" if $course_code;
885 $result .= ", $course_date<br/>" if $course_date;
886 $result .= "Учебный центр $course_center <br/>" if $course_center;
887 $result .= "</p>";
888 }
890 $result .= <<HEADER;
891 <table width='100%'>
892 <tr>
893 <td width='*'>
895 <table border=0 id='toc' class='toc'>
896 <tr>
897 <td>
898 <div class='toc_title'>Содержание</div>
899 <ul>
900 <li><a href='#log'>Журнал</a></li>
901 <ul>$toc</ul>
902 <li><a href='#files'>Файлы</a></li>
903 <li><a href='#stat'>Статистика</a></li>
904 <li><a href='#help'>Справка</a></li>
905 <li><a href='#about'>О программе</a></li>
906 </ul>
907 </td>
908 </tr>
909 </table>
911 </td>
912 <td valign='top' width=200>$control_form</td>
913 </tr>
914 </table>
915 HEADER
917 return $result;
918 }
921 #############
922 # print_footer
923 #
924 #
925 #
926 #
927 #
929 sub print_footer
930 {
931 return "</body>\n</html>\n";
932 }
937 #############
938 # print_stat
939 #
940 #
941 #
942 # In:
943 # Out:
945 sub print_stat
946 {
947 %StatNames = (
948 FirstCommand => "Время первой команды журнала",
949 LastCommand => "Время последней команды журнала",
950 TotalCommands => "Количество командных строк в журнале",
951 ErrorsPercentage => "Процент команд с ненулевым кодом завершения, %",
952 MistypesPercentage => "Процент синтаксически неверно набранных команд, %",
953 TotalTime => "Суммарное время работы с терминалом <sup><font size='-2'>*</font></sup>, час",
954 CommandsPerTime => "Количество командных строк в единицу времени, команда/мин",
955 CommandsFrequency => "Частота использования команд",
956 RareCommands => "Частота использования этих команд < 0.5%",
957 );
958 @StatOrder = (
959 FirstCommand,
960 LastCommand,
961 TotalCommands,
962 ErrorsPercentage,
963 MistypesPercentage,
964 TotalTime,
965 CommandsPerTime,
966 CommandsFrequency,
967 RareCommands,
968 );
970 # Подготовка статистики к выводу
971 # Некоторые значения пересчитываются!
972 # Дальше их лучше уже не использовать!!!
974 my %CommandsFrequency = %CommandsFDistribution;
976 $Stat{TotalTime} ||= 0;
977 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Stat{FirstCommand} || 0);
978 $Stat{FirstCommand} = sprintf "%02i:%02i:%02i %04i-%2i-%2i", $hour, $min, $sec, $year+1900, $mon+1, $mday;
979 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($Stat{LastCommand} || 0);
980 $Stat{LastCommand} = sprintf "%02i:%02i:%02i %04i-%2i-%2i", $hour, $min, $sec, $year+1900, $mon+1, $mday;
981 if ($Stat{TotalCommands}) {
982 $Stat{ErrorsPercentage} = sprintf "%5.2f", $Stat{ErrorCommands}*100/$Stat{TotalCommands};
983 $Stat{MistypesPercentage} = sprintf "%5.2f", $Stat{MistypedCommands}*100/$Stat{TotalCommands};
984 }
985 $Stat{CommandsPerTime} = sprintf "%5.2f", $Stat{TotalCommands}*60/$Stat{TotalTime}
986 if $Stat{TotalTime};
987 $Stat{TotalTime} = sprintf "%5.2f", $Stat{TotalTime}/60/60;
989 my $total_commands=0;
990 for $command (keys %CommandsFrequency){
991 $total_commands += $CommandsFrequency{$command};
992 }
993 if ($total_commands) {
994 for $command (reverse sort {$CommandsFrequency{$a} <=> $CommandsFrequency{$b}} keys %CommandsFrequency){
995 my $command_html;
996 my $percentage = sprintf "%5.2f",$CommandsFrequency{$command}*100/$total_commands;
997 if ($percentage < 0.5) {
998 my $hint = make_comment($command);
999 $command_html = "$command";
1000 $command_html = "<span title='$hint' class='with_hint'>$command_html</span>" if $hint;
1001 $command_html = "<span class='without_hint'>$command_html</span>" if not $hint;
1002 my $command_html = "<tt>$command_html</tt>";
1003 $Stat{RareCommands} .= $command_html."<sub><font size='-2'>".$CommandsFrequency{$command}."</font></sub> , ";
1005 else {
1006 my $hint = make_comment($command);
1007 $command_html = "$command";
1008 $command_html = "<span title='$hint' class='with_hint'>$command_html</span>" if $hint;
1009 $command_html = "<span class='without_hint'>$command_html</span>" if not $hint;
1010 my $command_html = "<tt>$command_html</tt>";
1011 $percentage = sprintf "%5.2f",$percentage;
1012 $Stat{CommandsFrequency} .= "<tr><td>".$command_html."</td><td>".$CommandsFrequency{$command}."</td>".
1013 "<td>|".("="x int($CommandsFrequency{$command}*100/$total_commands))."| $percentage%</td></tr>";
1016 $Stat{CommandsFrequency} = "<table>".$Stat{CommandsFrequency}."</table>";
1017 $Stat{RareCommands} =~ s/, $// if $Stat{RareCommands};
1020 my $result = q();
1021 for my $stat (@StatOrder) {
1022 next unless $Stat{"$stat"};
1023 $result .= "<tr valign='top'><td width='300'>".$StatNames{"$stat"}."</td><td>".$Stat{"$stat"}."</td></tr>"
1025 $result = "<table>$result</table>"
1026 . "<font size='-2'>____<br/>*) Интервалы неактивности длительностью "
1027 . ($Config{stat_inactivity_interval}/60)
1028 . " минут и более не учитываются</font></br>";
1030 return $result;
1034 sub collapse_list($)
1036 my $res = "";
1037 for my $elem (@{$_[0]}) {
1038 if (ref $elem eq "ARRAY") {
1039 $res .= "<ul>".collapse_list($elem)."</ul>";
1041 else
1043 $res .= "<li>".$elem."</li>";
1046 return $res;
1050 sub print_files
1052 my $result = qq();
1053 my @toc;
1054 for my $file (sort keys %Files) {
1055 my $div_id = $file;
1056 $div_id =~ s@/@_@g;
1057 push @toc, "<a href='#$div_id'>$file</a>";
1058 $result .= "<div class='filename' id='$div_id'>".$file."</div>\n"
1059 . "<div class='filedata'><pre>".$Files{$file}."</pre></div>";
1061 return "<div class='files_toc'>".collapse_list(\@toc)."</div>".$result;
1065 sub init_variables
1067 $Html_Help = <<HELP;
1068 Для того чтобы использовать LiLaLo, не нужно знать ничего особенного:
1069 всё происходит само собой.
1070 Однако, чтобы ведение и последующее использование журналов
1071 было как можно более эффективным, желательно иметь в виду следующее:
1072 <ol>
1073 <li><p>
1074 В журнал автоматически попадают все команды, данные в любом терминале системы.
1075 </p></li>
1076 <li><p>
1077 Для того чтобы убедиться, что журнал на текущем терминале ведётся,
1078 и команды записываются, дайте команду w.
1079 В поле WHAT, соответствующем текущему терминалу,
1080 должна быть указана программа script.
1081 </p></li>
1082 <li><p>
1083 Команды, при наборе которых были допущены синтаксические ошибки,
1084 выводятся перечёркнутым текстом:
1085 <table>
1086 <tr class='command'>
1087 <td class='script'>
1088 <pre class='_mistyped_cline'>
1089 \$ l s-l</pre>
1090 <pre class='_mistyped_output'>bash: l: command not found
1091 </pre>
1092 </td>
1093 </tr>
1094 </table>
1095 <br/>
1096 </p></li>
1097 <li><p>
1098 Если код завершения команды равен нулю,
1099 команда была выполнена без ошибок.
1100 Команды, код завершения которых отличен от нуля, выделяются цветом.
1101 <table>
1102 <tr class='command'>
1103 <td class='script'>
1104 <pre class='_wrong_cline'>
1105 \$ test 5 -lt 4</pre>
1106 </pre>
1107 </td>
1108 </tr>
1109 </table>
1110 Обратите внимание на то, что код завершения команды может быть отличен от нуля
1111 не только в тех случаях, когда команда была выполнена с ошибкой.
1112 Многие команды используют код завершения, например, для того чтобы показать результаты проверки
1113 <br/>
1114 </p></li>
1115 <li><p>
1116 Команды, ход выполнения которых был прерван пользователем, выделяются цветом.
1117 <table>
1118 <tr class='command'>
1119 <td class='script'>
1120 <pre class='_interrupted_cline'>
1121 \$ find / -name abc</pre>
1122 <pre class='interrupted_output'>find: /home/devi-orig/.gnome2: Keine Berechtigung
1123 find: /home/devi-orig/.gnome2_private: Keine Berechtigung
1124 find: /home/devi-orig/.nautilus/metafiles: Keine Berechtigung
1125 find: /home/devi-orig/.metacity: Keine Berechtigung
1126 find: /home/devi-orig/.inkscape: Keine Berechtigung
1127 ^C
1128 </pre>
1129 </td>
1130 </tr>
1131 </table>
1132 <br/>
1133 </p></li>
1134 <li><p>
1135 Команды, выполненные с привилегиями суперпользователя,
1136 выделяются слева красной чертой.
1137 <table>
1138 <tr class='command'>
1139 <td class='script'>
1140 <pre class='_root_cline'>
1141 # id</pre>
1142 <pre class='_root_output'>
1143 uid=0(root) gid=0(root) Gruppen=0(root)
1144 </pre>
1145 </td>
1146 </tr>
1147 </table>
1148 <br/>
1149 </p></li>
1150 <li><p>
1151 Изменения, внесённые в текстовый файл с помощью редактора,
1152 запоминаются и показываются в журнале в формате ed.
1153 Строки, начинающиеся символом "&lt;", удалены, а строки,
1154 начинающиеся символом "&gt;" -- добавлены.
1155 <table>
1156 <tr class='command'>
1157 <td class='script'>
1158 <pre class='cline'>
1159 \$ vi ~/.bashrc</pre>
1160 <table><tr><td width='5'/><td class='diff'><pre>2a3,5
1161 &gt; if [ -f /usr/local/etc/bash_completion ]; then
1162 &gt; . /usr/local/etc/bash_completion
1163 &gt; fi
1164 </pre></td></tr></table></td>
1165 </tr>
1166 </table>
1167 <br/>
1168 </p></li>
1169 <li><p>
1170 Для того чтобы изменить файл в соответствии с показанными в диффшоте
1171 изменениями, можно воспользоваться командой patch.
1172 Нужно скопировать изменения, запустить программу patch, указав в
1173 качестве её аргумента файл, к которому применяются изменения,
1174 и всавить скопированный текст:
1175 <table>
1176 <tr class='command'>
1177 <td class='script'>
1178 <pre class='cline'>
1179 \$ patch ~/.bashrc</pre>
1180 </td>
1181 </tr>
1182 </table>
1183 В данном случае изменения применяются к файлу ~/.bashrc
1184 </p></li>
1185 <li><p>
1186 Для того чтобы получить краткую справочную информацию о команде,
1187 нужно подвести к ней мышь. Во всплывающей подсказке появится краткое
1188 описание команды.
1189 </p>
1190 <p>
1191 Если справочная информация о команде есть,
1192 команда выделяется голубым фоном, например: <span class="with_hint" title="главный текстовый редактор Unix">vi</span>.
1193 Если справочная информация отсутствует,
1194 команда выделяется розовым фоном, например: <span class="without_hint">notepad.exe</span>.
1195 Справочная информация может отсутствовать в том случае,
1196 если (1) команда введена неверно; (2) если распознавание команды LiLaLo выполнено неверно;
1197 (3) если информация о команде неизвестна LiLaLo.
1198 Последнее возможно для редких команд.
1199 </p></li>
1200 <li><p>
1201 Большие, в особенности многострочные, всплывающие подсказки лучше
1202 всего показываются браузерами KDE Konqueror, Apple Safari и Microsoft Internet Explorer.
1203 В браузерах Mozilla и Firefox они отображаются не полностью,
1204 а вместо перевода строки выводится специальный символ.
1205 </p></li>
1206 <li><p>
1207 Время ввода команды, показанное в журнале, соответствует времени
1208 <i>начала ввода командной строки</i>, которое равно тому моменту,
1209 когда на терминале появилось приглашение интерпретатора
1210 </p></li>
1211 <li><p>
1212 Имя терминала, на котором была введена команда, показано в специальном блоке.
1213 Этот блок показывается только в том случае, если терминал
1214 текущей команды отличается от терминала предыдущей.
1215 </p></li>
1216 <li><p>
1217 Вывод не интересующих вас в настоящий момент элементов журнала,
1218 таких как время, имя терминала и других, можно отключить.
1219 Для этого нужно воспользоваться <a href='#visibility_form'>формой управления журналом</a>
1220 вверху страницы.
1221 </p></li>
1222 <li><p>
1223 Небольшие комментарии к командам можно вставлять прямо из командной строки.
1224 Комментарий вводится прямо в командную строку, после символов #^ или #v.
1225 Символы ^ и v показывают направление выбора команды, к которой относится комментарий:
1226 ^ - к предыдущей, v - к следующей.
1227 Например, если в командной строке было введено:
1228 <pre class='cline'>
1229 \$ whoami
1230 </pre>
1231 <pre class='output'>
1232 user
1233 </pre>
1234 <pre class='cline'>
1235 \$ #^ Интересно, кто я?
1236 </pre>
1237 в журнале это будет выглядеть так:
1239 <pre class='cline'>
1240 \$ whoami
1241 </pre>
1242 <pre class='output'>
1243 user
1244 </pre>
1245 <table class='note'><tr><td width='100%' class='note_text'>
1246 <tr> <td> Интересно, кто я?<br/> </td></tr></table>
1247 </p></li>
1248 <li><p>
1249 Если комментарий содержит несколько строк,
1250 его можно вставить в журнал следующим образом:
1251 <pre class='cline'>
1252 \$ whoami
1253 </pre>
1254 <pre class='output'>
1255 user
1256 </pre>
1257 <pre class='cline'>
1258 \$ cat > /dev/null #^ Интересно, кто я?
1259 </pre>
1260 <pre class='output'>
1261 Программа whoami выводит имя пользователя, под которым
1262 мы зарегистрировались в системе.
1264 Она не может ответить на вопрос о нашем назначении
1265 в этом мире.
1266 </pre>
1267 В журнале это будет выглядеть так:
1268 <table>
1269 <tr class='command'>
1270 <td class='script'>
1271 <pre class='cline'>
1272 \$ whoami</pre>
1273 <pre class='output'>user
1274 </pre>
1275 <table class='note'><tr><td class='note_title'>Интересно, кто я?</td></tr><tr><td width='100%' class='note_text'>
1276 Программа whoami выводит имя пользователя, под которым<br/>
1277 мы зарегистрировались в системе.<br/>
1278 <br/>
1279 Она не может ответить на вопрос о нашем назначении<br/>
1280 в этом мире.<br/>
1281 </td></tr></table>
1282 </td>
1283 </tr>
1284 </table>
1285 Для разделения нескольких абзацев между собой
1286 используйте символ "-", один в строке.
1287 <br/>
1288 </p></li>
1289 <li><p>
1290 Комментарии, не относящиеся непосредственно ни к какой из команд,
1291 добавляются точно таким же способом, только вместо симолов #^ или #v
1292 нужно использовать символы #=
1293 </p></li>
1294 </ol>
1295 HELP
1297 $Html_About = <<ABOUT;
1298 <p>
1299 LiLaLo (L3) расшифровывается как Live Lab Log.<br/>
1300 Программа разработана для повышения эффективности обучения Unix/Linux-системам.<br/>
1301 (c) Игорь Чубин, 2004-2006<br/>
1302 </p>
1303 ABOUT
1304 $Html_About.='$Id$ </p>';
1306 $Html_JavaScript = <<JS;
1307 function getElementsByClassName(Class_Name)
1309 var Result=new Array();
1310 var All_Elements=document.all || document.getElementsByTagName('*');
1311 for (i=0; i<All_Elements.length; i++)
1312 if (All_Elements[i].className==Class_Name)
1313 Result.push(All_Elements[i]);
1314 return Result;
1316 function ShowHide (name)
1318 elements=getElementsByClassName(name);
1319 for(i=0; i<elements.length; i++)
1320 if (elements[i].style.display == "none")
1321 elements[i].style.display = "";
1322 else
1323 elements[i].style.display = "none";
1324 //if (elements[i].style.visibility == "hidden")
1325 // elements[i].style.visibility = "visible";
1326 //else
1327 // elements[i].style.visibility = "hidden";
1329 function filter_by_output(text)
1332 var jjj=0;
1334 elements=getElementsByClassName('command');
1335 for(i=0; i<elements.length; i++) {
1336 subelems = elements[i].getElementsByTagName('pre');
1337 for(j=0; j<subelems.length; j++) {
1338 if (subelems[j].className = 'output') {
1339 var str = new String(subelems[j].nodeValue);
1340 if (jjj != 1) {
1341 alert(str);
1342 jjj=1;
1344 if (str.indexOf(text) >0)
1345 subelems[j].style.display = "none";
1346 else
1347 subelems[j].style.display = "";
1355 JS
1357 %Search_Machines = (
1358 "google" => { "query" => "http://www.google.com/search?q=" ,
1359 "icon" => "$Config{frontend_google_ico}" },
1360 "freebsd" => { "query" => "http://www.freebsd.org/cgi/man.cgi?query=",
1361 "icon" => "$Config{frontend_freebsd_ico}" },
1362 "linux" => { "query" => "http://man.he.net/?topic=",
1363 "icon" => "$Config{frontend_linux_ico}"},
1364 "opennet" => { "query" => "http://www.opennet.ru/search.shtml?words=",
1365 "icon" => "$Config{frontend_opennet_ico}"},
1366 "local" => { "query" => "http://www.freebsd.org/cgi/man.cgi?query=",
1367 "icon" => "$Config{frontend_local_ico}" },
1369 );
1371 %Elements_Visibility = (
1372 "0 new_commands_table" => "новые команды",
1373 "1 diff" => "редактор",
1374 "2 time" => "время",
1375 "3 ttychange" => "терминал",
1376 "4 wrong_output wrong_cline wrong_root_output wrong_root_cline"
1377 => "команды с ненулевым кодом завершения",
1378 "5 mistyped_output mistyped_cline mistyped_root_output mistyped_root_cline"
1379 => "неверно набранные команды",
1380 "6 interrupted_output interrupted_cline interrupted_root_output interrupted_root_cline"
1381 => "прерванные команды",
1382 "7 tab_completion_output tab_completion_cline"
1383 => "продолжение с помощью tab"
1384 );
1386 @Day_Name = qw/ Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота /;
1387 @Month_Name = qw/ Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь /;
1388 @Of_Month_Name = qw/ Января Февраля Марта Апреля Мая Июня Июля Августа Сентября Октября Ноября Декабря /;
1394 # Временно удалённый код
1395 # Возможно, он не понадобится уже никогда
1398 sub search_by
1400 my $sm = shift;
1401 my $topic = shift;
1402 $topic =~ s/ /+/;
1404 return "<a href='". $Search_Machines{$sm}->{"query"}."$topic'><img width='16' height='16' src='".
1405 $Search_Machines{$sm}->{"icon"}."' border='0'/></a>";