forked from jasononeil/OpenRoadFTP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
52 lines (43 loc) · 1.21 KB
/
index.php
File metadata and controls
52 lines (43 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<pre>
You'll notice this can get quite slow quite quickly.
We'll want to limit it to only dig a certain number of directories deep each time.
We'll also want to cache a copy on the server, I think the FTP calls legitimately slow it down.
And then there's the question, is it better to get one directory list at a time, and have it load fast
Or to pre cache a few deep?
<?php
$connection = ftp_connect("localhost");
$isLoginOkay = @ftp_login($connection,"jason","1Cor13") ? 'true' : 'false';
echo "Connected and logged in? " . $isLoginOkay;
echo "\n" . "Current working directory: " . ftp_pwd($connection);
$limit = 1;
printDirectory("/WebRoot/winthrop/");
function printDirectory($dir, $gap = "")
{
global $connection;
global $limit; echo $limit;
if (strlen($gap) > $limit) { return false; }
$fileList = ftp_nlist($connection, $dir);
foreach ($fileList as $id=>$filename)
{
echo "\n" . $gap . $id . " - " . $filename;
if (ftp_is_dir($filename))
{
printDirectory($filename, $gap . "=");
}
}
}
function ftp_is_dir($file)
{
global $connection;
if (@ftp_chdir($connection, $file))
{
ftp_chdir($connection, '/');
return true;
}
else
{
return false;
}
}
?>
</pre>