#!/usr/bin/perl # Created by Pete@ELBnet.com Copyright 2003 ELB Internet Services, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use DBI; # Set Unique Job Number $JOB=localtime; $num_copies = 1; if($ARGV[0] ne ""){ `cat $ARGV[0] > '/home/spool/$JOB'`; }else{ # Spool Job open (FILE, "> /home/spool/$JOB") or die "PRINTING ERROR - 1"; print FILE ; while () { print FILE ; } close (FILE); } $ENV{'DISPLAY'} =~ m/^(ws\d\d?)\./; $who = $1; # Count Pages open(FILE, "< /home/spool/$JOB") or die "PRINTING ERROR!"; $print_job = ; foreach $item () { if ($item =~ /^%%Pages:.*/) { $item =~ m/^%%Pages:\s(.*)/; $num_pages = $1; #if ($num_pages ne "(atend)"){ # last; }elsif ($item =~ /.*NumCopies\s(\d*)/){ $num_copies = $1 } # For AbiWord Page Count if ($item =~ /^%%Page\s\d+\s\d+/) { $item =~ m/^%%Page\s(\d+)\s\d+/; $num_pages = $1; } } close (FILE); # Count Total Pages Printed my $dbh = DBI->connect('DBI:mysql:passwords','passwords','GetEmNow43'); $sth = $dbh->prepare("select pages from passwords where kiosk=?"); $sth->execute($who); @data = $sth->fetchrow_array; $sth->finish; $prev_pages = $data[0]; $num_pages = $num_pages * $num_copies; $tot_pages = $num_pages + $prev_pages; # Create Page Count Message open (FILE, "> /home/spool/$JOB-message"); if ($num_pages == 1){ print FILE "\n\n You have requested to print 1 page \n\n"; }else{ print FILE "\n\n You have requested to print $num_pages pages \n\n"; } $price = ($tot_pages - 5) * .20; if ( $price < 0 ){ $price = 0;} printf FILE (" You will owe a total of \$%.2f \n", $price); print FILE " (this includes $prev_pages pages already printed) \n\n\n"; print FILE " PICK UP PRINT JOBS AT FRONT (circulation) DESK \n\n\n"; close (FILE); # Show message $result=`/usr/bin/X11/xmessage -buttons "Print":1,"Cancel":2 -print -center -file "/home/spool/$JOB-message"`; # Display Page Message if ($result eq "Print\n") { # if ($who eq "ws10" || $who eq "ws11" || $who eq "ws12" || $who eq "ws13"){ # `/bin/mv '/home/spool/$JOB' /home/spool/children/`; # }else{ `/bin/mv '/home/spool/$JOB' /home/spool/adult/`; # } $sth = $dbh->prepare("update passwords set pages=? where kiosk=?"); $sth->execute($tot_pages,$who); $sth->finish; } $dbh->disconnect; `rm -f '/home/spool/$JOB'`; `rm -f /home/spool/'$JOB-message'`; exit;