devi@27: #!/usr/bin/perl
devi@27:
devi@27: use strict;
devi@27: use CGI qw(:standard);
devi@30: use XML::Simple;
devi@46: use utf8;
devi@30:
devi@30: BEGIN {
devi@30: chdir("/home/devi/cvs/lilalo");
devi@30: require l3config;
devi@30: };
devi@27:
devi@37: my %filter;
devi@32:
devi@37: for my $key (qw(login_from)) {
devi@37: $filter{$key} = param($key) if param($key);
devi@42: $filter{$key} = $ENV{$key} if defined $ENV{$key};
devi@32: }
devi@27:
devi@30: my %Trainings;
devi@30: my $XMLTraining;
devi@30: my %Machines;
devi@42: my $print = "";
devi@30:
devi@47: my $is_not_cgi="";
devi@47: $is_not_cgi = "1" if defined($ENV{l3_to_file});
devi@47: # Пока что мы считаем, что вызов выполняется через CGI,
devi@47: # если не установлена переменная l3_to_file
devi@47: # Это неверно, но как временное решение - пойдёт
devi@47:
devi@47: $l3config::Config{frontend_css} =~ s@^/@@ if $is_not_cgi;
devi@47:
devi@30: sub load_training
devi@30: {
devi@30: my $classfile =
devi@30: $_[0]||
devi@30: $l3config::Config{"classfile"} ||
devi@30: $l3config::Config{"path_classes"}."/".$l3config::Config{"class"}.$l3config::Config{"class_suffix"};
devi@30:
devi@30: my $XMLTraining = XMLin($classfile , ForceArray => [ 'student' ] )
devi@32: or die "Can't open file of the training ",$classfile,"\n";
devi@30:
devi@30: for my $student (@{$XMLTraining->{"student"}}) {
devi@30: $XMLTraining->{host}->{$student->{"host"}}=$student;
devi@30: }
devi@30: return $XMLTraining;
devi@30: }
devi@30:
devi@29:
devi@29:
devi@30: if ($ENV{PATH_INFO} eq "/index") {
devi@30: # Показываем индекс курсов
devi@30: my @training_files = glob($l3config::Config{"path_classes"}."/*".$l3config::Config{"class_suffix"});
devi@30: if (@training_files) {
devi@30: for my $training_file (@training_files) {
devi@30: my $training = load_training($training_file);
devi@30: $Trainings{$training->{"date"}}=$training;
devi@30: }
devi@42: $print .= "\n";
devi@42: $print .= "