lilalo

changeset 42:5499496e2462

Печать сначала в переменную, а потом всё выводим сразу
author devi
date Tue Nov 22 23:49:32 2005 +0200 (2005-11-22)
parents 6452bfe549d1
children a717ea245c90
files l3-cgi lm
line diff
     1.1 --- a/l3-cgi	Tue Nov 22 23:27:51 2005 +0200
     1.2 +++ b/l3-cgi	Tue Nov 22 23:49:32 2005 +0200
     1.3 @@ -13,11 +13,13 @@
     1.4  
     1.5  for my $key (qw(login_from)) {
     1.6  	$filter{$key} =  param($key) if param($key);
     1.7 +	$filter{$key} = $ENV{$key} if defined $ENV{$key};
     1.8  }
     1.9  
    1.10  my %Trainings;
    1.11  my $XMLTraining;
    1.12  my %Machines;
    1.13 +my $print = "";
    1.14  
    1.15  sub load_training
    1.16  {
    1.17 @@ -35,7 +37,7 @@
    1.18  	return $XMLTraining;
    1.19  }
    1.20  
    1.21 -print header(
    1.22 +$print .= header(
    1.23  		-charset => "utf-8", 
    1.24  		);
    1.25  
    1.26 @@ -48,87 +50,87 @@
    1.27  			my $training = load_training($training_file);
    1.28  			$Trainings{$training->{"date"}}=$training;
    1.29  		}
    1.30 -		print "<html>\n";
    1.31 -		print "<head>\n";
    1.32 -		print "<title>Журналы лабораторных работ</title>\n";
    1.33 -		print "</head>\n";
    1.34 -		print "<body>\n";
    1.35 -		print "<table>\n";
    1.36 +		$print .= "<html>\n";
    1.37 +		$print .= "<head>\n";
    1.38 +		$print .= "<title>Журналы лабораторных работ</title>\n";
    1.39 +		$print .= "</head>\n";
    1.40 +		$print .= "<body>\n";
    1.41 +		$print .= "<table>\n";
    1.42  		for my $tdate (reverse sort keys %Trainings) {
    1.43  			my $t = $Trainings{$tdate};
    1.44 -			print "<tr>";
    1.45 -			print "<td>".$t->{date}."</td>";
    1.46 -			print "<td>".$t->{course}."</td>";
    1.47 -			print "</tr>\n";
    1.48 -			print "<tr>";
    1.49 -			print "<td/>";
    1.50 -			print "<td><pre>";
    1.51 +			$print .= "<tr>";
    1.52 +			$print .= "<td>".$t->{date}."</td>";
    1.53 +			$print .= "<td>".$t->{course}."</td>";
    1.54 +			$print .= "</tr>\n";
    1.55 +			$print .= "<tr>";
    1.56 +			$print .= "<td/>";
    1.57 +			$print .= "<td><pre>";
    1.58  			for my $host (sort keys %{$t->{host}}) {
    1.59  				my $h = $t->{host}->{$host};
    1.60 -				print "$host";
    1.61 -				print " ".$h->{firstname}." ".$h->{surname}." ";
    1.62 -				print "<a href='/cgi-bin/l3/".$tdate."/".$host."/root'>root</a> ";
    1.63 -				print "<a href='/cgi-bin/l3/".$tdate."/".$host."/".$h->{user}."'>".$h->{user}."</a> ";
    1.64 -				print "\n";
    1.65 +				$print .= "$host";
    1.66 +				$print .= " ".$h->{firstname}." ".$h->{surname}." ";
    1.67 +				$print .= "<a href='/cgi-bin/l3/".$tdate."/".$host."/root'>root</a> ";
    1.68 +				$print .= "<a href='/cgi-bin/l3/".$tdate."/".$host."/".$h->{user}."'>".$h->{user}."</a> ";
    1.69 +				$print .= "\n";
    1.70  			}
    1.71 -			print "</pre><td>";
    1.72 -			print "</tr>\n";
    1.73 +			$print .= "</pre><td>";
    1.74 +			$print .= "</tr>\n";
    1.75  		}
    1.76 -		print "</table>\n";
    1.77 -		print "</body>\n";
    1.78 -		print "</html>\n";
    1.79 +		$print .= "</table>\n";
    1.80 +		$print .= "</body>\n";
    1.81 +		$print .= "</html>\n";
    1.82  	}
    1.83  	else {
    1.84 -		print "No training-files found<br/>\n";
    1.85 -		print "Template to load files: ".$l3config::Config{"path_classes"}."*".$l3config::Config{"class_suffix"}."\n"
    1.86 +		$print .= "No training-files found<br/>\n";
    1.87 +		$print .= "Template to load files: ".$l3config::Config{"path_classes"}."*".$l3config::Config{"class_suffix"}."\n"
    1.88  	}
    1.89  }
    1.90  elsif ($ENV{PATH_INFO} eq "/current/index" || $ENV{PATH_INFO} eq "") {
    1.91  	my $t = load_training();
    1.92  
    1.93 -	print "<html>\n";
    1.94 -	print "<head>\n";
    1.95 -	print "<title>Журналы лабораторных работ</title>\n";
    1.96 -	print "<link rel='stylesheet' href='".$l3config::Config{frontend_css}."' type='text/css'/>\n";
    1.97 -	print "</head>\n";
    1.98 -	print "<body>\n";
    1.99 -	print "<h1>Журналы лабораторных работ</h1>\n";
   1.100 -	print "<table>\n";
   1.101 -	print "<tr class='table_header'>\n";
   1.102 -	print "<td>"."Имя"."</td>";
   1.103 -	print "<td>Хост</td>";
   1.104 -	print "<td colspan='3'>Пользователь</td>";
   1.105 -	print "</tr>\n";
   1.106 +	$print .= "<html>\n";
   1.107 +	$print .= "<head>\n";
   1.108 +	$print .= "<title>Журналы лабораторных работ</title>\n";
   1.109 +	$print .= "<link rel='stylesheet' href='".$l3config::Config{frontend_css}."' type='text/css'/>\n";
   1.110 +	$print .= "</head>\n";
   1.111 +	$print .= "<body>\n";
   1.112 +	$print .= "<h1>Журналы лабораторных работ</h1>\n";
   1.113 +	$print .= "<table>\n";
   1.114 +	$print .= "<tr class='table_header'>\n";
   1.115 +	$print .= "<td>"."Имя"."</td>";
   1.116 +	$print .= "<td>Хост</td>";
   1.117 +	$print .= "<td colspan='3'>Пользователь</td>";
   1.118 +	$print .= "</tr>\n";
   1.119  	for my $host (sort keys %{$t->{host}}) {
   1.120  
   1.121  		my $prefix = "/cgi-bin/l3/current/";
   1.122  		my $suffix = "";
   1.123  		
   1.124 -		print "<tr>\n";
   1.125 +		$print .= "<tr>\n";
   1.126  		my $h = $t->{host}->{$host};
   1.127 -		print "<td>".$h->{firstname}." ".$h->{surname}."</td>";
   1.128 -		print "<td>$host</td>";
   1.129 -		print "<td><a href='".$prefix.$host."/root$suffix'>root</a></td>";
   1.130 -		print "<td><a href='".$prefix.$host."/".$h->{user}."$suffix'>".$h->{user}."</a></td>";
   1.131 -		print "<td><a href='".$prefix.$host."$suffix'>все</a></td>";
   1.132 -		print "</td>\n";
   1.133 -		print "</tr>\n";
   1.134 +		$print .= "<td>".$h->{firstname}." ".$h->{surname}."</td>";
   1.135 +		$print .= "<td>$host</td>";
   1.136 +		$print .= "<td><a href='".$prefix.$host."/root$suffix'>root</a></td>";
   1.137 +		$print .= "<td><a href='".$prefix.$host."/".$h->{user}."$suffix'>".$h->{user}."</a></td>";
   1.138 +		$print .= "<td><a href='".$prefix.$host."$suffix'>все</a></td>";
   1.139 +		$print .= "</td>\n";
   1.140 +		$print .= "</tr>\n";
   1.141  	}
   1.142 -	print "<tr>\n";
   1.143 -	print "<td>"."Инструктор"."</td>";
   1.144 -	print "<td>from linux.nt</td>";
   1.145 -	print "<td/>";
   1.146 -	print "<td/>";
   1.147 -	print "<td><a href='/cgi-bin/l3/current"."?login_from=192.168.15.254'>все</a></td>";
   1.148 -	print "</tr>\n";
   1.149 -	print "</table>\n";
   1.150 -	print "</body>\n";
   1.151 -	print "</html>\n";
   1.152 +	$print .= "<tr>\n";
   1.153 +	$print .= "<td>"."Инструктор"."</td>";
   1.154 +	$print .= "<td>from linux.nt</td>";
   1.155 +	$print .= "<td/>";
   1.156 +	$print .= "<td/>";
   1.157 +	$print .= "<td><a href='/cgi-bin/l3/current"."?login_from=192.168.15.254'>все</a></td>";
   1.158 +	$print .= "</tr>\n";
   1.159 +	$print .= "</table>\n";
   1.160 +	$print .= "</body>\n";
   1.161 +	$print .= "</html>\n";
   1.162  }
   1.163  elsif ($ENV{PATH_INFO} eq "/current") {
   1.164  	open (FRONTEND, "./l3-frontend --output - --show_comments no |");
   1.165  	while (<FRONTEND>) {
   1.166 -		print;
   1.167 +		$print .=;
   1.168  	}
   1.169  	close(FRONTEND);
   1.170  }
   1.171 @@ -160,8 +162,9 @@
   1.172  
   1.173  	open (FRONTEND, "./l3-frontend ".join(" ",map("\"$_\"",@args))." |");
   1.174  	while (<FRONTEND>) {
   1.175 -		print;
   1.176 +		$print .= $_;
   1.177  	}
   1.178  	close(FRONTEND);
   1.179  }
   1.180  
   1.181 +print $print;
     2.1 --- a/lm	Tue Nov 22 23:27:51 2005 +0200
     2.2 +++ b/lm	Tue Nov 22 23:49:32 2005 +0200
     2.3 @@ -129,9 +129,6 @@
     2.4  
     2.5  sub load_scripts
     2.6  {
     2.7 -	print join " ", %Config;
     2.8 -	print "\n";
     2.9 -
    2.10  	open (SCRIPTS, "$Config{l3scripts}")
    2.11  		or die "Cant open l3scripts file: ".$Config{l3scripts}.": $!\n";
    2.12  	binmode SCRIPTS, ":utf8";