#!/usr/bin/perl use strict; use HTML::Entities (); #----------------------------------------------------------- # jQuery File Tree Perl Connector # # Version 1.0 # # Oleg Burlaca # http://www.burlaca.com/2009/02/jquery-file-tree-connector/ # 12 February 2009 #----------------------------------------------------------- # for security reasons, specify a root folder # to prevent the whole filesystem to be shown # for ex: the root folder of your webbrowser my $root = "/var/www/html/"; #---------------------------------------------------------- my $params = &getCGIParams(); print "Content-type: text/html\n\n"; my $dir = $params->{dir}; my $fullDir = $root . $dir; exit if ! -e $fullDir; opendir(BIN, $fullDir) or die "Can't open $dir: $!"; my (@folders, @files); my $total = 0; while( defined (my $file = readdir BIN) ) { next if $file eq '.' or $file eq '..'; $total++; if (-d "$fullDir/$file") { push (@folders, $file); } else { push (@files, $file); } } closedir(BIN); return if $total == 0; print "