Messenger Stuff Community Forums

Full Version: File Browser (Non Ajax); Version 1.0 - Pre Release
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a pre-release of the File Browser which you can get here*:

Someone really wanted it so I packaged and tested it so that anyone can use it.

Example usage & download; http://h-master.net/svn/fb/filebrowser.php
Direct Download; -> here <-

Current To Do List:
- Hidden Files and Folders
Lets you 'hide' folders or files you don't want users to see.
- Control Panel
Makes it easy for people with no PHP/JS/CSS skills
- Group Showing
Lets you choose which groups to show (name, type etc).

Developers:
PHP
filebrowser.php - editing the filename should still make everything work.
In the bottom of the main file are the functions used to show and format the files and folders.
The main function is _foldersort() and that creates an array for the current folder in use. It returns either the file or the array and ascending/descending what group.
The ones prefixed format_xxx() just sort out the raw text produced from _foldersort().

Javascript
functions.js - If you rename the file change the script tag in the header of the main php file (filebrowser.php by default).
The preview() function is the main one which shows the onmouseover box of image files.
Two functions [ makeRequest() and loading() ] are not used in the non-ajax version.

CSS
style.css - If you rename the file change the link tag in the header of the main php file (filebrowser.php by default).
Very basic and easy to edit =).

Icons
The current icons are in the images/ folder and are from famfamfam.
You can add you own by putting the icons in the images/ directory and updating the format_filetype() function in main php file (filebrowser.php by default).

Any ideas, options, code improvements welcome =). Have fun!

* Only the non-ajax version for the time being.
Very nice (Y), and great that you have made it open source :p

Suggestion: make it so it can also be used when called index.php and in a folder called "filebrowser" but still finds all the files in either the root directory or the directory above it, or (probably a better idea/alternative) make it so it uses mod_rewrite so that if it is in the root directory then it is something like domain.com/filebrowser/some-folder/

hmaster Wrote:* Only the non-ajax version for the time being.
:(
the andyman Wrote:Very nice (Y), and great that you have made it open source :p
Open Source ftw (Y).

the andyman Wrote:Suggestion: make it so it can also be used when called index.php and in a folder called "filebrowser" but still finds all the files in either the root directory or the directory above it.
It can still do that, but I put in a security fix because then you can browse all files on the same server (I found a way to get to all the files on skarz.co.uk using a simple exploit).
You can however try it out and see if you can find a proper workaround.
Go to the main php file (filebrowser.php by default).
Find :
PHP Code:
#assign vars

if(isset($_GET['fol']) && strlen($_GET['fol']) > 0) {
    
#security fix
    
if($_GET['fol']{0} == "/" || substr($_GET['fol'], 03) == "../") {
        
$thisfolder "./";
    } else {
        
$thisfolder $_GET['fol']."/";
    }
    
$thisfolder str_replace("../"""$thisfolder);
} else {
    
$thisfolder "./";

and change to
PHP Code:
#assign vars

if(isset($_GET['fol']) && strlen($_GET['fol']) > 0) {
    
$thisfolder $_GET['fol']."/";
} else {
    
$thisfolder "./";

Now if you try in a browser ?fol=../../ or w/e it will go to other directories.

:idear: Maybe if I added a variable to add the name of a root folder and so if someone tries to go higher than that then it shows an error or goes to the root.

the andyman Wrote:or (probably a better idea/alternative) make it so it uses mod_rewrite so that if it is in the root directory then it is something like domain.com/filebrowser/some-folder/
Never thought of that, I'll try it out and keep you updated.

the andyman Wrote:
hmaster Wrote:* Only the non-ajax version for the time being.
:(
It's coming soon, maybe tomorrow if I don't get any work!

Thanks .Lou for the heads up on the php bbcode tag =).
Very Nice, I'll be using it(Y).
Seems nice, can be handy. I might use it in the future :)

Btw, I'd just like to point out to everyone that there is a php tag, usable like the code one.
Code:
[php]&[/php]

This allows for easy and fast php syntax highlighting:

PHP Code:
#assign vars

if(isset($_GET['fol']) && strlen($_GET['fol']) > 0) {
$thisfolder $_GET['fol']."/";
} else {
$thisfolder "./";

Reference URL's