#!/usr/bin/ruby # vi: ts=4 sw=4 require 'philesight' require 'cgi' # Config variables db = "./ps.db" default_path = "/" size = 800 show_list = true use_gradients = true # Get parameters from environment and CGI. ISMAP image maps do not return a # proper CGI parameter, but only the coordinates appended after a question # mark. If this is found in the QUERY_STRING, assume the 'find' command cgi = CGI.new; qs = ENV["QUERY_STRING"] cmd = cgi.params['cmd'][0] path = cgi.params['path'][0] || default_path if(qs && qs =~ /\?(\d+,\d+)/ ) then find_pos = $1 cmd = 'find' end ps = Philesight.new(4, size, use_gradients) ps.db_open(db) # Perform action depending on 'cmd' parameter case cmd when "img" puts "Content-type: image/png" puts $stdout.flush ps.draw(path, "-") when "find" if(find_pos =~ /(\d+),(\d+)/) then x, y = $1.to_i, $2.to_i url = "?path=%s" % ps.find(path, x, y) puts "Content-type: text/html" puts puts '' puts '' puts '
' puts ' ' puts ' ' puts '' puts '' puts '' end else random = "" 1.upto(32) { random += (rand(26) + ?a).chr } puts "Content-type: text/html" puts puts '' puts '' puts '' puts ' ' puts "Filename | Size |
' + content[0][:path].to_s + ' | ' + content[0][:humansize].to_s + ' |
' + f[:path].to_s + ' | ' + f[:humansize].to_s + ' |