1#!/usr/local/bin/perl 2# view_job.cgi 3# View an existing print job 4 5require './lpadmin-lib.pl'; 6&ReadParse(); 7 8@jobs = &get_jobs($in{'name'}); 9foreach $j (@jobs) { 10 $job = $j if ($j->{'id'} eq $in{'id'}); 11 } 12($ju = $j->{'user'}) =~ s/\!.*$//; 13&can_edit_jobs($in{'name'}, $ju) || &error($text{'view_ecannot'}); 14if ($job) { 15 # print job exists.. dump it 16 @pf = @{$job->{'printfile'}}; 17 $type = &backquote_command("file ".quotemeta($pf[0]), 1); 18 if ($type =~ /postscript/i) { 19 print "Content-type: application/postscript\n"; 20 } 21 elsif ($type =~ /text/) { 22 print "Content-type: text/plain\n"; 23 } 24 else { 25 print "Content-type: application/octet-stream\n"; 26 } 27 foreach $pf (@pf) { 28 @st = stat($pf); 29 $total += $st[7]; 30 } 31 print "Content-length: $total\n"; 32 print "\n"; 33 foreach $pf (@pf) { 34 open(FILE, "<$pf"); 35 while(<FILE>) { print; } 36 close(FILE); 37 } 38 } 39else { 40 &error(&text('view_egone', $in{'id'})); 41 } 42 43