TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-30-2008, 06:04 PM   #1 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default Browser-based FTP browser

Hey all!

Currently I've been working, just for the fun of it, on a FTP browser. Nothing fancy or anything, but I just want to get some help and feedback if possible.

Imagine a index structure like so;
Code:
download
    public
        concepts
        ftpconcept.doc
    private
    ftp
        dumpfile.jpg
    storage
sandbox
    playground
talkphp
    boards
        advanced_programming
            topic
                browser-based_ftp_browser
                    topic.html
index.html
script.js
style.css
image.jpg
As you can see, there are 3 (three) maps named download, sandbox and talkphp. Some of them or in this case, all of them contain a subfolder and at some they contain either a file, directory or even worse, both.
Next to that, the root ( . ) ( « no, that's not a boob) contains files as well. Naturally, the directories are ALSO located in the root because we start scanning from there on out.

Now, for the fun part. I already got this;
PHP Code:
    $directories     = array();
    
$files             = array();
    
$dirHandle         opendir('.'); // root
    
$disgardType    = array(".""..""index.php"".htaccess");

    while (
false !== ($targetFile readdir($dirHandle))) {
        
        if (!
in_array($targetFile2$disgardType)) { 
            
            if (
is_file($targetFile)) {
                
//array_push($files, $targetFile);
            
}
            
            if (
is_dir($targetFile)) {
                
//array_push($directories, $targetFile);
                
if (is_dir($targetFile)) {
                    
$dirHandle2 opendir($targetFile);
                    while (
false !== ($targetFile2 readdir($dirHandle2))) {
                        if (!
in_array($targetFile2$disgardType)) { 
                            
//array_push($directories, $targetFile2);
                        

                        
                    }
                }
            }
        } 
    }
    
closedir($dirHandle); 
But this all made me wonder quite a bit. I've got, as it stands right now, 4 subdirectories based in talkphp. Even the worst paranoid mapping structure specialist should be able to use this so there should be NO limit to what the level of depth should be.

Now, I can scan the first sublevel of directires which would give me (for example) under download: public, private, ftp and storage. But what if I scanned talkPHP? I should make ANOTHER level of subdirectory checks in a while loop, INSIDE my script (again). If that's so, I can just keep going and going making the same loop over and over and over again. I think you all get where I am going with this.

Can somebody offer some insight on how to do this the GOOD way? Oh yea, as a footnote, I would like to be able to display them so that they SHOW UP as subdirectories in a print_r() function. So under download as key 0, I should get this;
Code:
Array
(
    [download] => Array
        (
            [public] => Array
                (
                    [0] => concepts
                    [1] => ftpconcept.doc
                )

            [0] => private
            [ftp] => Array
                (
                    [0] => dumpfile.jpg
                )

            [storage] => Array
                (
                    [0] => playground
                )

        )
)

Thanks in advance,
ReSpawN
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 10-31-2008, 04:38 PM   #2 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Seriously ... no one?
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 11-01-2008, 12:04 AM   #3 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Bumper di bump... Come on codefreaks, gimme some help here...
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 11-01-2008, 10:21 AM   #4 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

First of all you wont get any answers faster by bumbing :P
second is have you tried google searches, to see if someone else might have done this already. for ideas etc.. ps this would be allot easier in java :) just saying.. hum some more information maybe could get you more answers well..
ps: have you tried some your self ? maybe could post what you have tried..

-Codefreek!
codefreek is offline  
Reply With Quote
Old 11-01-2008, 01:46 PM   #5 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Quote:
Originally Posted by codefreek View Post
First of all you wont get any answers faster by bumbing :P
second is have you tried google searches, to see if someone else might have done this already. for ideas etc.. ps this would be allot easier in java :) just saying.. hum some more information maybe could get you more answers well..
ps: have you tried some your self ? maybe could post what you have tried..

-Codefreek!
Dude, seriously.

Alright, I will elaborate. I searched the web like a crazy bot, asked some friends, tried a bunch of ways on my own and so forth. All the outcomes where unsatisfactory.

There you have it. If no one is just able to help me and just post some sort of spam then simply never mind. Codefreek, please, next time, just post a serious response instead of posting the obvious to gaining posts.

Sorry, but this made me pretty cranky.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 11-01-2008, 02:55 PM   #6 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

I knew that I wrote something similar ages ago. After searching for hours (very messy file system!) I found it. There's no guarantees that it'll even work but I think it did what you're looking for.

http://phpfi.com/372392
Salathe is offline  
Reply With Quote
Old 11-01-2008, 04:58 PM   #7 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

I'll give it a look-see. Thanks Salathe!
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:08 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design