#!/mod/bin/jimsh

package require cgi
source /mod/webif/lib/setup
require ts.class queue.class

httpheader

set dir [cgi_get dir]
set act [cgi_get act -]
if {$act eq "-"} {
	puts "No action."
	exit;
}

puts "<div id=deleting class=blood><img src=/img/spin.gif>Queuing...</div>"
puts "<ul style=\"list-style-type: square\">"

foreach file [cgi_get files] {
	puts -nonewline "<li>\"$file\"..."

	if {[string first "$dir/" $file] != 0} {
		puts "Error - outside directory."
		continue
	}

	set ts [ts fetch $file]
	if {$ts eq "0"} continue

	lassign $act xact args

	set q [queue insert -hold $ts $xact]
	if {$args ne ""} { $q set args $args }
	$q submit
	puts "</li>"
}
puts "</ul>"

