summaryrefslogtreecommitdiffstats
path: root/philesight/philesight.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'philesight/philesight.cgi')
-rwxr-xr-xphilesight/philesight.cgi127
1 files changed, 0 insertions, 127 deletions
diff --git a/philesight/philesight.cgi b/philesight/philesight.cgi
deleted file mode 100755
index 969269a..0000000
--- a/philesight/philesight.cgi
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/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 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
- puts '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >'
- puts '<head>'
- puts ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'
- puts ' <meta http-equiv="refresh" content="0; url=' + "#{url}" + '">'
- puts '</head>'
- puts '<body></body>'
- puts '</html>'
- end
-
- else
- random = ""
- 1.upto(32) { random += (rand(26) + ?a).chr }
- puts "Content-type: text/html"
- puts
- puts '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
- puts '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >'
- puts '<head>'
- puts ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'
- puts " <title>Disk usage : #{path}</title>"
- puts ' <style type="text/css">'
- puts ' <!--'
- puts ' body {color:black;text-align:center;background:#FAFAFA;}'
- puts ' table {margin:auto;width:780px;}'
- puts ' table,td {border:0;}'
- puts ' td {padding:4px;text-align:left;}'
- puts ' td.size {text-align:right;}'
- puts ' thead td {font-weight:bold;border-bottom:1px solid black;background:#EEE;}'
- puts ' tbody td {background:#F0F0F0;}'
- puts ' tbody tr.parentdir td {background:#E5D0D0;}'
- puts ' tbody tr.evenrow td {background:#E4E4E4;}'
- puts ' '
- puts ' -->'
- puts ' </style>'
- puts '</head>'
- puts '<body>'
- puts ' <p><a href="' + "?path=#{path}&amp;" + '">'
- puts ' <img style="border:0" width="#{size}" height="#{size}" src="?cmd=img&amp;r=' + "#{random}&amp;path=#{path}" + '" ismap="ismap" alt="' + "#{path}" + '" />'
- puts ' </a></p>'
-
- if show_list then
- # Array of files
- content = ps.listcontent("#{path}")
- if(content && content[0]) then
- puts ' <table summary="File lists">'
- puts ' <thead>'
- puts ' <tr><td>Filename</td><td class="size">Size</td></tr>'
- puts ' </thead>'
- puts ' <tbody>'
- puts ' <tr class="parentdir"><td>' + content[0][:path].to_s + '</td><td class="size">' + content[0][:humansize].to_s + '</td></tr>'
-
- if(content[1].size > 0) then
- linenum = 0
-
- content[1] = content[1].sort_by { |f| - f[:size] }
- content[1].each do |f|
- if(linenum%2 == 0) then
- print ' <tr class="evenrow">'
- else
- print ' <tr>'
- end
-
- puts '<td><a href="?path='+ CGI.escape(f[:path].to_s) +'">' + f[:path].to_s + '</a></td><td class="size">' + f[:humansize].to_s + '</td></tr>'
-
- linenum += 1
- end
- end
- puts ' </tbody>'
- puts ' </table>'
- end
- end
-
- puts '</body>'
- puts '</html>'
-end
-
-#
-# End
-#
-