Permalink
Browse files

Deleted unsupported connectors, rewrote PHP connector

  • Loading branch information...
1 parent 11067cf commit a8a423abad3964d833d1605be3e6797c5eb9445c Jak Spalding committed Aug 2, 2012
@@ -1,44 +0,0 @@
-<%
-'
-' jQuery File Tree ASP (VBS) Connector
-' Copyright 2008 Chazzuka
-' programmer@chazzuka.com
-' http://www.chazzuka.com/
-'
-' retrive base directory
-dim BaseFileDir:BaseFileDir=Request.Form("dir")
-' if blank give default value
-if len(BaseFileDir)=0 then BaseFileDir="/userfiles/"
-
-dim ObjFSO,BaseFile,Html
-' resolve the absolute path
-BaseFile = Server.MapPath(BaseFileDir)&"\"
-' create FSO
-Set ObjFSO = Server.CreateObject("Scripting.FileSystemObject")
-' if given folder is exists
-if ObjFSO.FolderExists(BaseFile) then
- dim ObjFolder,ObjSubFolder,ObjFile,i__Name,i__Ext
- Html = Html + "<ul class=""jqueryFileTree"" style=""display: none;"">"&VBCRLF
- Set ObjFolder = ObjFSO.GetFolder(BaseFile)
- ' LOOP THROUGH SUBFOLDER
- For Each ObjSubFolder In ObjFolder.SubFolders
- i__Name=ObjSubFolder.name
- Html = Html + "<li class=""directory collapsed"">"&_
- "<a href=""#"" rel="""+(BaseFileDir+i__Name+"/")+""">"&_
- (i__Name)+"</a></li>"&VBCRLF
- Next
- 'LOOP THROUGH FILES
- For Each ObjFile In ObjFolder.Files
- ' name
- i__Name=ObjFile.name
- ' extension
- i__Ext = LCase(Mid(i__Name, InStrRev(i__Name, ".", -1, 1) + 1))
- Html = Html + "<li class=""file ext_"&i__Ext&""">"&_
- "<a href=""#"" rel="""+(BaseFileDir+i__Name)+""">"&_
- (i__name)+"</a></li>"&VBCRLF
- Next
- Html = Html + "</ul>"&VBCRLF
-end if
-
-Response.Write Html
-%>
@@ -1,31 +0,0 @@
-<%@ Page Language="C#" AutoEventWireup="true" %>
-
-<%
- //
- // jQuery File Tree ASP Connector
- //
- // Version 1.0
- //
- // Copyright (c)2008 Andrew Sweeny
- // asweeny@fit.edu
- // 24 March 2008
- //
- string dir;
- if(Request.Form["dir"] == null || Request.Form["dir"].Length <= 0)
- dir = "/";
- else
- dir = Server.UrlDecode(Request.Form["dir"]);
- System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(dir);
- Response.Write("<ul class=\"jqueryFileTree\" style=\"display: none;\">\n");
- foreach (System.IO.DirectoryInfo di_child in di.GetDirectories())
- Response.Write("\t<li class=\"directory collapsed\"><a href=\"#\" rel=\"" + dir + di_child.Name + "/\">" + di_child.Name + "</a></li>\n");
- foreach (System.IO.FileInfo fi in di.GetFiles())
- {
- string ext = "";
- if(fi.Extension.Length > 1)
- ext = fi.Extension.Substring(1).ToLower();
-
- Response.Write("\t<li class=\"file ext_" + ext + "\"><a href=\"#\" rel=\"" + dir + fi.Name + "\">" + fi.Name + "</a></li>\n");
- }
- Response.Write("</ul>");
- %>
@@ -1,19 +0,0 @@
-<!---
-
-jQuery File Tree
-ColdFusion connector script
-By Tjarko Rikkerink (http://carlosgallupa.com/)
-
---->
-<cfparam name="form.dir" default="/somedir" />
-<cfdirectory action="LIST" directory="#expandpath('#URLDecode(form.dir)#')#" name="qDir" sort="type, name" type="all" listinfo="all" recurse="no">
-
-<ul class="jqueryFileTree" style="display: none;">
- <cfoutput query="qDir">
- <cfif type eq "dir">
- <li class="directory collapsed"><a href="##" rel="#URLDecode(form.dir)##name#/">#name#</a></li>
- <cfelseif type eq "file">
- <li class="file ext_#listLast(name,'.')#"><a href="##" rel="#URLDecode(form.dir)##name#">#name# (#round(size/1024)#KB)</a></li>
- </cfif>
- </cfoutput>
-</ul>
@@ -1,43 +1,41 @@
<?php
-//
-// jQuery File Tree PHP Connector
-//
-// Version 1.01
-//
-// Cory S.N. LaViska
-// A Beautiful Site (http://abeautifulsite.net/)
-// 24 March 2008
-//
-// History:
-//
-// 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
-// 1.00 - released (24 March 2008)
-//
-// Output a list of files for jQuery File Tree
-//
-
-$_POST['dir'] = urldecode($_POST['dir']);
-
-if( file_exists($root . $_POST['dir']) ) {
- $files = scandir($root . $_POST['dir']);
- natcasesort($files);
- if( count($files) > 2 ) { /* The 2 accounts for . and .. */
- echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
- // All dirs
- foreach( $files as $file ) {
- if( file_exists($root . $_POST['dir'] . $file) && $file != '.' && $file != '..' && is_dir($root . $_POST['dir'] . $file) ) {
- echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a></li>";
- }
- }
- // All files
- foreach( $files as $file ) {
- if( file_exists($root . $_POST['dir'] . $file) && $file != '.' && $file != '..' && !is_dir($root . $_POST['dir'] . $file) ) {
- $ext = preg_replace('/^.*\./', '', $file);
- echo "<li class=\"file ext_$ext\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "\">" . htmlentities($file) . "</a></li>";
- }
- }
- echo "</ul>";
- }
+
+// Configuration
+$hideDotFiles = true;
+$rootDirectory = './'; // Must have trailing slash
+
+// Define the path
+$dir = $_GET['dir'] ? $_GET['dir'] : $argv[1];
+
+// Sanitize user input
+$dir = str_replace('..', '', $dir);
+
+// Set up a place to store the output
+$results = array();
+
+// Add a trailing slash to the directory (for string concatenation)
+if (substr($dir, -1, 1) !== DIRECTORY_SEPARATOR) {
+ $dir .= DIRECTORY_SEPARATOR;
}
-?>
+$dir = $rootDirectory . $dir;
+
+if (is_dir($dir)) {
+ foreach (scandir($dir) as $name) {
+ // Skip the relative directories
+ if ($name == '.' || $name == '..') continue;
+ // Skip dotfiles if not wanted
+ if ($hideDotFiles && substr($name, 0, 1) == '.') continue;
+
+ $entry = array(
+ 'name' => $name,
+ 'dir' => is_dir($dir . $name)
+ );
+
+ $results[] = $entry;
+ }
+ echo json_encode($results);
+} else {
+ // If the parameter is not a directory, die.
+ throw new Exception("Invalid directory specified - " . $dir);
+}
@@ -1,102 +0,0 @@
-#!/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 "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
-
-# print Folders
-foreach my $file (sort @folders) {
- next if ! -e $fullDir . $file;
-
- print '<li class="directory collapsed"><a href="#" rel="' .
- &HTML::Entities::encode($dir . $file) . '/">' .
- &HTML::Entities::encode($file) . '</a></li>';
-}
-
-# print Files
-foreach my $file (sort @files) {
- next if ! -e $fullDir . $file;
-
- $file =~ /\.(.+)$/;
- my $ext = $1;
- print '<li class="file ext_' . $ext . '"><a href="#" rel="' .
- &HTML::Entities::encode($dir . $file) . '/">' .
- &HTML::Entities::encode($file) . '</a></li>';
-}
-
-print "</ul>\n";
-
-
-
-
-#--------------------------------------------------------------------------------------------------
-sub getCGIParams {
- my $line;
-
- if ($ENV{'REQUEST_METHOD'} eq "POST") {
- read(STDIN, $line, $ENV{'CONTENT_LENGTH'});
- } else {
- $line = $ENV{'QUERY_STRING'};
- }
-
- my (@pairs) = split(/&/, $line);
- my ($name, $value, %F);
-
- foreach (@pairs) {
- ($name, $value) = split(/=/);
- $value =~ tr/+/ /;
- $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
-
- if (! exists $F{$name}) {
- $F{$name} = $value;
- } elsif (exists $F{$name} and ref($F{$name}) ne 'ARRAY') {
- my $prev_value = $F{$name};
- delete $F{$name};
- $F{$name} = [ $prev_value, $value ];
- } else { push @{ $F{$name} }, $value }
- }
- return \%F;
-}
-#--------------------------------------------------------------------------------------------------
-
@@ -1,25 +0,0 @@
-#
-# jQuery File Tree
-# Python/Django connector script
-# By Martin Skou
-#
-import os
-import urllib
-
-def dirlist(request):
- r=['<ul class="jqueryFileTree" style="display: none;">']
- try:
- r=['<ul class="jqueryFileTree" style="display: none;">']
- d=urllib.unquote(request.POST.get('dir','c:\\temp'))
- for f in os.listdir(d):
- ff=os.path.join(d,f)
- if os.path.isdir(ff):
- r.append('<li class="directory collapsed"><a href="#" rel="%s/">%s</a></li>' % (ff,f))
- else:
- e=os.path.splitext(f)[1][1:] # get .ext and remove dot
- r.append('<li class="file ext_%s"><a href="#" rel="%s">%s</a></li>' % (e,ff,f))
- r.append('</ul>')
- except Exception,e:
- r.append('Could not load directory: %s' % str(e))
- r.append('</ul>')
- return HttpResponse(''.join(r))
@@ -1,36 +0,0 @@
-[
- //
- // jQuery File Tree Lasso Connector
- //
- // Version 1.00
- //
- // Jason Huck
- // http://devblog.jasonhuck.com/
- // 1 May 2008
- //
- // History:
- //
- // 1.00 - released (1 May 2008)
- //
- // Output a list of files for jQuery File Tree
- //
-
- !action_param('dir') ? abort;
- var('dir') = action_param('dir');
- var('files') = file_listdirectory($dir);
-
- '<ul class="jqueryFileTree" style="display: none;">';
-
- iterate($files, local('file'));
- #file->beginswith('.') ? loop_continue;
-
- if(#file->endswith('/'));
- '<li class="directory collapsed"><a href="#" rel="' + $dir + #file + '">' + #file + '</a></li>';
- else;
- local('ext') = #file->split('.')->last;
- '<li class="file ext_' + #ext + '"><a href="#" rel="' + $dir + #file + '">' + #file + '</a></li>';
- /if;
- /iterate;
-
- '</ul>';
-]
Oops, something went wrong.

0 comments on commit a8a423a

Please sign in to comment.