[ Avaa Bypassed ]




Upload:

Command:

www-data@18.218.26.136: ~ $
# cups-lib.pl
# Functions for CUPS printer management

$lpstat = &has_command("lpstat.cups") ? "lpstat.cups" : "lpstat";
$lpadmin = &has_command("lpadmin.cups") ? "lpadmin.cups" : "lpadmin";
$lpr = &has_command("lpr.cups") ? "lpr.cups" : "lpr";
$lprm = &has_command("lprm.cups") ? "lprm.cups" : "lprm";
$lpq = &has_command("lpq.cups") ? "lpq.cups" : "lpq";

# list_printers()
# Returns an array of known printer names
sub list_printers
{
return () if (!&sched_running());
local(@rv, $_);
open(STAT, "$lpstat -v |");
while(<STAT>) {
	if (/\s+for\s+(\S+):/i) { push(@rv, $1); }
	}
close(STAT);
return &unique(@rv);
}

# get_printer(name, [nostatus])
# Returns a reference to an associative array of printer details
sub get_printer
{
local($stat, @rv, $body, $avl, $con, $sys, %prn, $_, $out);
local $esc = quotemeta($_[0]);
$out = &backquote_command("$lpstat -l -p $esc", 1);
return undef if ($out =~ /non-existent\s+printer/);
if ($out =~ /^printer\s+(\S+)\s+(\S+).*\n([\000-\377]*)$/) {
	# printer exists..
	$prn{'name'} = $1;
	$prn{'enabled'} = $2 ne "disabled";
	$body = $3;
	}
else {
	# no printer found
	return undef;
	}
if (!$prn{'enabled'} && $body =~ /^\s+(.*)/) {
	$prn{'enabled_why'} = lc($1) eq "paused" || lc($1) eq "reason unknown" ?
			      "" : $1;
	}
if ($body =~ /Description: (.*)/) { $prn{'desc'} = $1; }
if ($body =~ /Printer types: (.*)/) { $prn{'ptype'} = $1; }
if ($body =~ /Interface: (.*)/) { $prn{'iface'} = $1; }
if ($body =~ /Banner not required/) { $prn{'banner'} = 0; }
else { $prn{'banner'} = 1; }

if (!$_[1]) {
	# request availability
	$avl = &backquote_command("$lpstat -a $prn{'name'} 2>&1", 1);
	if ($avl =~ /^\S+\s+not accepting.*\n\s*(.*)/) {
		$prn{'accepting'} = 0;
		$prn{'accepting_why'} = lc($1) eq "reason unknown" ? "" : $1;
		}
	else { $prn{'accepting'} = 1; }
	}

# Try to find the device URI, from printers.conf or lpstat -v
local $uri;
foreach my $file ("/etc/printers.conf", "/etc/cups/printers.conf") {
	next if (!-r $file);
	local $lref = &read_file_lines($file);
	local $inprinter;
	foreach $l (@$lref) {
		if ($l =~ /^\s*<(Default)?Printer\s+(\S+)>/) {
			# Start of a new printer
			$inprinter = $2;
			}
		elsif ($l =~ /^\s*DeviceURI\s+(.*)/ &&
		       $inprinter eq $prn{'name'}) {
			$uri = $1;
			}
		}
	}
if (!$uri) {
	$con = &backquote_command("$lpstat -v $prn{'name'} 2>&1", 1);
	if ($con =~ /^device for \S+:\s+(\S+)/) {
		$uri = $1;
		}
	}

# request connection
if ($uri =~ /^(lpd|ipp):\/\/([^\s\/]+)\/(\S+)/) {
	$prn{'rhost'} = $2;
	$prn{'rqueue'} = $3;
	if ($1 eq 'ipp') {
		$prn{'rtype'} = 'ipp';
		$prn{'rhost'} =~ s/:631//;
		}
	else {
		$prn{'rhost'} =~ s/:515//;
		}
	}
elsif ($uri =~ /^socket:\/\/(\S+):(\d+)/) {
	$prn{'dhost'} = $1;
	$prn{'dport'} = $2;
	}
elsif ($uri =~ /^(file|serial|parallel|usb):([^\s\?]+)/) {
	$prn{'dev'} = $2;
	}
else {
	$prn{'dev'} = $uri;
	}

# Check if this is the default printer
if (&backquote_command("$lpstat -d 2>&1", 1) =~ /destination:\s+(\S+)/ &&
    $1 eq $prn{'name'}) {
	$prn{'default'} = 1;
	}

return \%prn;
}

# get_jobs(printer)
sub get_jobs
{
local (@jobs, $htype);
local $esc = quotemeta($_[0]);
open(LPQ, "$lpq -P$esc |");
while(<LPQ>) {
	s/\r|\n//g;
	next if (/^Rank/i || /^$_[0]/);
	if (/^(\S+)\s+(\S+)\s+(\d+)\s+(.*\S)\s+(\d+)\s+(\S.*)$/ ||
	    /^(\S+)\s+(\S{1,8}?)\s*(\d+)\s+(.*\S)\s+(\d+)\s+(\S.*)$/) {
		# Normal lpq output
		local(%job, $f, @pq);
		$job{'id'} = $3;
		$job{'user'} = $2;
		$job{'size'} = $5;
		$job{'file'} = $4;
		$job{'printing'} = ($1 eq "active");
		local $d = $config{'spool_dir'};
		opendir(DIR, $d);
		while($f = readdir(DIR)) {
			if ($f =~ /^d(\d+)\-(\d+)$/ && $1 == $job{'id'}) {
				push(@pq, "$d/$f");
				local @st = stat("$d/$f");
				if (@st) {
					$job{'time'} ||= $st[9];
					}
				}
			}
		closedir(DIR);
		$job{'printfile'} = @pq ? \@pq : undef;
		if ($job{'time'}) {
			$job{'when'} = &make_date($job{'time'});
			}
		push(@jobs, \%job);
		}
	}
close(LPQ);
return @jobs;
}

# printer_support(option)
sub printer_support
{
return $_[0] !~ /^(msize|alias|rnoqueue|ctype|sysv|allow)$/;
}

# list_classes()
# Returns an associative array of print classes
sub list_classes
{
local($stat, %rv);
$stat = &backquote_command("$lpstat -c 2>&1", 1);
while($stat =~ /^members of class (\S+):\n((\s+\S+\n)+)([\000-\377]*)$/) {
	$stat = $4;
	$rv{$1} = [ grep { $_ ne "" } split(/\s+/, $2) ];
	}
return \%rv;
}

# create_printer(&details)
# Create a new printer
sub create_printer
{
&modify_printer($_[0]);
}

# modify_printer(&details)
# Change an existing printer
sub modify_printer
{
local(%prn, $cmd, $out);
%prn = %{$_[0]};

# call lpadmin
local $esc = quotemeta($prn{'name'});
local $desc = quotemeta($prn{'desc'}) || "''";
$cmd = "$lpadmin -p $esc -D $desc";
local $vesc = quotemeta($prn{'dev'});
if ($prn{'dev'} =~ /\/dev\/tty/) {
	$cmd .= " -v serial:$vesc";
	}
elsif ($prn{'dev'} =~ /\/dev\/lp/) {
	$cmd .= " -v parallel:$vesc";
	}
elsif ($prn{'dev'} =~ /\/dev\/usb/) {
	$cmd .= " -v usb:$vesc";
	}
elsif ($prn{'dev'}) {
	$cmd .= " -v $vesc";
	}
elsif ($prn{'rhost'}) {
	local $resc = quotemeta($prn{'rhost'});
	local $qesc = quotemeta($prn{'rqueue'});
	if ($prn{'rtype'} eq 'ipp') {
		$cmd .= " -v ipp://$resc/$qesc";
		}
	else {
		$cmd .= " -v lpd://$resc/$qesc";
		}
	}
else {
	local $resc = quotemeta($prn{'dhost'});
	local $pesc = quotemeta($prn{'dport'});
	$cmd .= " -v socket://$resc:$pesc";
	}
if ($prn{'iface'}) {
	local $iesc = quotemeta($prn{'iface'});
	$cmd .= " -i $iesc";
	}
foreach $o (keys %$cups_driver_options) {
	$cmd .= " -o ".quotemeta($o)."=".quotemeta($cups_driver_options->{$o});
	}
$out = &backquote_logged("cd / ; $cmd 2>&1");
if ($?) { &error("$lpadmin failed : <pre>$out</pre>"); }

# make the default
if ($prn{'default'}) {
	$out = &backquote_logged("cd / ; $lpadmin -d $esc 2>&1");
	if ($?) { &error("Failed to set default : <pre>$out</pre>"); }
	}

# enable or disable
local $enable = &has_command("cupsenable") || &has_command("enable");
local $disable = &has_command("cupsdisable") || &has_command("disable");
if ($prn{'enabled'}) { $cmd = "$enable $esc"; }
elsif ($prn{'enabled_why'}) {
	local $wesc = quotemeta($prn{'enabled_why'});
	$cmd = "$enable $esc ; $disable -r $wesc $esc";
	}
else { $cmd = "$enable $esc ; $disable $esc"; }
$out = &backquote_logged("$cmd 2>&1");

# accepting or rejecting requests
if ($prn{'accepting'}) { $cmd = "accept $esc"; }
elsif ($prn{'accepting_why'}) {
	local $wesc = quotemeta($prn{'accepting_why'});
	$cmd = "accept $esc ; reject -r $wesc $esc";
	}
else { $cmd = "accept $esc ; reject $esc"; }
$out = &backquote_logged("$cmd 2>&1");
}

# delete_printer(name)
# Deletes some existing printer
sub delete_printer
{
local($out);
local $esc = quotemeta($_[0]);
$out = &backquote_logged("$lpadmin -x $esc 2>&1");
if ($?) { &error("$lpadmin failed : <pre>$out</pre>"); }
}

# cancel_job(printer, id)
# Cancels some print job
sub cancel_job
{
local($out);
local $esc = quotemeta($_[0]);
local $iesc = quotemeta($_[1]);
$out = &backquote_logged("$lprm -P$esc $iesc 2>&1");
if ($?) { &error("$lprm failed : <pre>$out</pre>"); }
sleep(1);
}

# sched_running()
# Returns the pid if lpsched is running, 0 if not, -1 if cannot be stopped
sub sched_running
{
@pid = &find_byname("cups");
if (@pid) { return $pid[0]; }
return 0;
}

# start_sched()
# Start lpsched
sub start_sched
{
local $out = &backquote_logged("cupsd 2>&1");
if ($?) { &error("failed to start cups : <tt>$out</tt>"); }
sleep(3);
}

# stop_sched(pid)
# Stop the running lpsched process
sub stop_sched
{
local @pid = ( &find_byname("cupsd") );
&kill_logged('TERM', @pid) || &error("Failed to stop cups : $!");
}

# print_command(printer, file)
# Returns the command to print some file on some printer
sub print_command
{
local $esc = quotemeta($_[0]);
local $fesc = quotemeta($_[1]);
return "$lpr -P$esc $fesc";
}

# check_print_system()
# Returns an error message if CUPS is not installed
sub check_print_system
{
&has_command($lpstat) || return &text('cups_ecmd', "<tt>$lpstat</tt>");
&has_command($lpadmin) || return &text('cups_ecmd', "<tt>$lpadmin</tt>");
return undef;
}

if (-r "/dev/lp0") {
	@device_files = ("/dev/lp0", "/dev/lp1", "/dev/lp2", "/dev/lp3",
			 "/dev/ttyS0", "/dev/ttyS1", "/dev/null");
	}
else {
	@device_files = ("/dev/lp1", "/dev/lp2", "/dev/lp2", "/dev/lp3",
			 "/dev/ttyS0", "/dev/ttyS1", "/dev/null");
	}
if (-r "/dev/usblp0") {
	push(@device_files, "/dev/usblp0", "/dev/usblp1",
			    "/dev/usblp2", "/dev/usblp3");
	}
elsif (-r "/dev/usb/lp0") {
	push(@device_files, "/dev/usb/lp0", "/dev/usb/lp1",
			    "/dev/usb/lp2", "/dev/usb/lp3");
	}
@device_names = (&text('linux_paralel', "1"), &text('linux_paralel', "2"),
		 &text('linux_paralel', "3"), &text('linux_paralel', "4"),
		 &text('linux_serial', "1"), &text('linux_serial', "2"),
		 $text{'linux_null'},  &text('linux_usb', 1),
		 &text('linux_usb', 2), &text('linux_usb', 3),
		 &text('linux_usb', 4));


Filemanager

Name Type Size Permission Actions
images Folder 0755
lang Folder 0755
CHANGELOG File 1.16 KB 0644
acl_security.pl File 4.4 KB 0755
aix-lib.pl File 9.45 KB 0755
ascii.txt File 4.19 KB 0644
base_coas_driver File 560 B 0755
bw.fig File 2.75 KB 0644
bw.ps File 6.46 KB 0644
caldera-driver.pl File 12.31 KB 0755
cancel_all.cgi File 535 B 0755
catalog.devices File 12.34 KB 0644
cgi_args.pl File 284 B 0755
cluster.cgi File 2.06 KB 0755
cluster_add.cgi File 2.13 KB 0755
cluster_delete.cgi File 529 B 0755
colour.fig File 2.91 KB 0644
colour.ps File 6.63 KB 0644
config-AlmaLinux-7.0-ALL File 323 B 0644
config-Amazon-Linux-2-ALL File 323 B 0644
config-CentOS-Linux-7.0-ALL File 323 B 0644
config-CentOS-Stream-Linux-8.0-ALL File 323 B 0644
config-CloudLinux-8.0-ALL File 323 B 0644
config-Oracle-Linux-8.0-ALL File 323 B 0644
config-Redhat-Enterprise-Linux-7.0-ALL File 323 B 0644
config-Rocky-Linux-7.0-ALL File 323 B 0644
config-Scientific-Linux-7.0-ALL File 323 B 0644
config-aix File 281 B 0644
config-coherent-linux File 323 B 0644
config-corel-linux File 228 B 0644
config-debian-linux File 228 B 0644
config-debian-linux-3.1-3.9 File 327 B 0644
config-debian-linux-4.0-ALL File 333 B 0644
config-freebsd File 230 B 0644
config-generic-linux File 228 B 0644
config-gentoo-linux File 248 B 0644
config-hpux File 323 B 0644
config-irix File 213 B 0644
config-macos File 230 B 0644
config-mandrake-linux File 245 B 0644
config-mandrake-linux-8.0-ALL File 276 B 0644
config-msc-linux File 228 B 0644
config-netbsd File 230 B 0644
config-open-linux File 309 B 0644
config-open-linux-3.1e File 239 B 0644
config-openSUSE-Linux-15.0-ALL File 318 B 0644
config-openbsd File 230 B 0644
config-openmamba-linux File 229 B 0644
config-pardus-linux File 228 B 0644
config-redhat-linux File 228 B 0644
config-redhat-linux-24.0-ALL File 339 B 0644
config-redhat-linux-7.0 File 283 B 0644
config-redhat-linux-7.1 File 286 B 0644
config-redhat-linux-7.2-8.1 File 394 B 0644
config-redhat-linux-9.0-23.0 File 337 B 0644
config-slackware-linux File 228 B 0644
config-slackware-linux-8.1-ALL File 246 B 0644
config-solaris File 304 B 0644
config-solaris-10-ALL File 330 B 0644
config-solaris-9 File 296 B 0644
config-suse-linux File 226 B 0644
config-suse-linux-8.2-ALL File 322 B 0644
config-trustix-linux File 313 B 0644
config-turbo-linux File 228 B 0644
config-united-linux File 322 B 0644
config-unixware File 302 B 0644
config.info File 1.31 KB 0644
config.info.ca File 1.53 KB 0644
config.info.cs File 1.25 KB 0644
config.info.de File 1.43 KB 0644
config.info.es File 1.17 KB 0644
config.info.fr File 1.63 KB 0644
config.info.hu File 707 B 0644
config.info.ja File 823 B 0644
config.info.nl File 1.41 KB 0644
config.info.no File 1.37 KB 0644
config.info.pl File 1.45 KB 0644
config.info.pt_BR File 1.58 KB 0644
config.info.ru File 1.74 KB 0644
config.info.sv File 651 B 0644
config.info.tr File 1.39 KB 0644
config.info.uk File 1.81 KB 0644
config.info.zh File 573 B 0644
config.info.zh_TW File 539 B 0644
cups-driver.pl File 6.37 KB 0755
cups-lib.pl File 8.67 KB 0755
defaultacl File 73 B 0644
delete_printer.cgi File 690 B 0755
delete_printers.cgi File 839 B 0755
drivers File 18.34 KB 0644
edit_printer.cgi File 10.08 KB 0755
freebsd-lib.pl File 7.26 KB 0755
hpux-driver.pl File 3.13 KB 0755
hpux-lib.pl File 9.83 KB 0755
index.cgi File 5.83 KB 0755
irix-driver.pl File 3.13 KB 0755
irix-lib.pl File 10.68 KB 0755
linux-lib.pl File 8.97 KB 0755
list_jobs.cgi File 2.25 KB 0755
log_parser.pl File 1021 B 0755
lpadmin-lib.pl File 19.89 KB 0755
lprng-lib.pl File 10.26 KB 0755
module.info File 494 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 159 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 223 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 290 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 306 B 0644
module.info.ca File 167 B 0644
module.info.ca.auto File 16 B 0644
module.info.cs File 31 B 0644
module.info.cs.auto File 155 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 168 B 0644
module.info.de File 148 B 0644
module.info.de.auto File 16 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 362 B 0644
module.info.es File 38 B 0644
module.info.es.auto File 157 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 217 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 246 B 0644
module.info.fi File 0 B 0644
module.info.fi.auto File 168 B 0644
module.info.fr File 39 B 0644
module.info.fr.auto File 176 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 205 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 188 B 0644
module.info.hu File 19 B 0644
module.info.hu.auto File 173 B 0644
module.info.it File 0 B 0644
module.info.it.auto File 177 B 0644
module.info.ja File 27 B 0644
module.info.ja.auto File 213 B 0644
module.info.ko File 25 B 0644
module.info.ko.auto File 176 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 219 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 189 B 0644
module.info.ms File 152 B 0644
module.info.ms.auto File 16 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 196 B 0644
module.info.nl File 33 B 0644
module.info.nl.auto File 133 B 0644
module.info.no File 31 B 0644
module.info.no.auto File 137 B 0644
module.info.pl File 160 B 0644
module.info.pl.auto File 16 B 0644
module.info.pt File 39 B 0644
module.info.pt.auto File 149 B 0644
module.info.pt_BR File 42 B 0644
module.info.pt_BR.auto File 155 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 199 B 0644
module.info.ru File 25 B 0644
module.info.ru.auto File 245 B 0644
module.info.sk File 0 B 0644
module.info.sk.auto File 184 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 192 B 0644
module.info.sv File 30 B 0644
module.info.sv.auto File 141 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 393 B 0644
module.info.tr File 27 B 0644
module.info.tr.auto File 166 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 281 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 304 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 189 B 0644
module.info.zh File 24 B 0644
module.info.zh.auto File 136 B 0644
module.info.zh_TW File 30 B 0644
module.info.zh_TW.auto File 142 B 0644
old-caldera-driver.pl File 9.74 KB 0755
openbsd-lib.pl File 7.26 KB 0755
prefs.info File 40 B 0644
printconf-driver.pl File 9.52 KB 0755
rbac-mapping File 248 B 0644
redhat-driver.pl File 12.42 KB 0755
restart.cgi File 301 B 0755
save_printer.cgi File 5.85 KB 0755
solaris-driver.pl File 4.03 KB 0755
solaris-lib.pl File 12.17 KB 0755
sortdrivers-by-drv.pl File 222 B 0755
sortdrivers.pl File 242 B 0755
start.cgi File 377 B 0755
stop.cgi File 374 B 0755
stp File 2.45 KB 0644
suse-driver.pl File 10.62 KB 0755
test_form.cgi File 887 B 0755
test_print.cgi File 1.19 KB 0755
unixware-lib.pl File 7.81 KB 0755
view_job.cgi File 909 B 0755
webmin-driver.pl File 1.04 KB 0755