What is this ?FeaturesHow does it work ?How to use it ?How to save a selected path from browse script to my form or code ?How to create the listener on a diffrent path or on the same file ?How to create your custom button ?What are the available options ?limitAccess OptiondenyAccess OptioncreateDirs OptionfilesType OptiondeniedFilesType OptionthemesPath OptionselectedTheme Optionview OptionactiveThumb - tempPath - siteTempPath OptionsA complete example 1A complete example 2

The
Express
Server Browse v1 . 0 . 0
The Ultimate Server Browse

What is this ?


The Express Server Browse is a simple code tool that helps you and your clients to easily browse the server with your specific options.

Features


How does it work ?


It's really simple, The default call format as the following:
1- Load the library.
<?PHP
include_once "lib/codesgit/browse.php";
?>
2- Call the class.
<?PHP
$browse = new codesGit_browse();
?>
3- Load headers between head tags on your page:
<head>
        <?PHP
        $browse->loadHeader();
        ?>
</head>
4- Create the browse button.
<body>
        <?PHP
           $browse->create("target_with_CSS_selector_format", 'path_to_listener_php_file.php', 'value="Choose file..."');
        ?>
</body>
5-Load the listener code.
<?PHP
$browse->listen();
?>

How to use it ?


1- Create your loader file for example: "load.php".
2- Create your specific options on an object variable.
<?PHP

$options->filesType = '*.php;*.js'; //select only php and javascript files 
$options->createDirs = FALSE; // TRUE = Ability to create new directory
$options->view = "grid";

?>
3- Load the library and call it.
<?PHP
include_once 'lib/codesgit/browse.php';

$browse = new codesGit_browse($options);
?>
4- Create your interface file for example: 'index.php' and write your HTML code containing the library codes and jQuery library.
<?PHP
//load the loader file
include_once "load.php";
?>
<html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <?PHP
        $browse->loadHeader();
        ?>
    </head>    
    <body>
        <div id="thePath">No Files Selected</div>
        <input type="text" class="thePath" value="No Files Selected" size="80" /><br>
        <?PHP
        $browse->create(".thePath, #thePath", 'browse.php', 'value="Choose the file from server..."');
        ?>
    </body>
</html>
5- Create the browse file for example: browse.php and add the listener code to it.
<?PHP
//load the loader file
include_once "load.php";

//Add listener code
$browse->listen();
?>
6- Run your code for example: "www.example.com/index.php".

How to save a selected path from browse script to my form or code ?


In Create function => $browse->create("target_with_CSS_selector_format", 'path_to_listener_php_file.php', 'Your custom button options');
replace the (target_with_CSS_selector_format) part with your target with css selector format.
For example:
Example for 2 targets: if the first one is DIV and its id called "thepath" and the second one is an input text where its class name is "serverpath", consequently you're going to use the following:
<div id="thePath">No Files Selected</div>
<input type="text" class="serverpath" value="No Files Selected" size="80" />
<?PHP
$browse->create("#thepath, .serverpath", 'path_to_listener_php_file.php', 'value="Choose file..."');
?>

How to create the listener on a diffrent path or on the same file ?


In Create function => $browse->create("target_with_CSS_selector_format", 'path_to_listener_php_file.php', 'Your custom button options');
replace the ('path_to_listener_php_file.php') part with the path of the PHP file containing the listener code($browse->listen()).
For example:
If the code is in the same file you can use the following:
<?PHP

if($_GET['browse'] == "true")
{
    //listener Part
    $browse->listen();      
}
?>
and you're going to call it like this: ''index.php?browse=true''.
<?PHP
$browse->create("target_with_CSS_selector_format", 'index.php?browse=true', 'Your custom button options');
?>
If the listener is in another file you can type the full URL to this file for example: ''http://www.example.com/browse.php?...etc''.

How to create your custom button ?


In Create function => $browse->create("target_with_CSS_selector_format", 'path_to_listener_php_file.php', 'Your custom button options');
replace the ('Your custom button options') part with your custom attributes.
For example:
If you want to add a specific class name and value ...etc the code will be like the following:
<?PHP
$browse->create("target_with_CSS_selector_format", 'path_to_listener_php_file.php', 'value="Open File..." class="buttons"');
?>

What are the available options ?


The options are as the following:

limitAccess Option


This option lets you to limit the user to browse the server inside a specific directory.
For example:
If you need to limit user to browse the directory: ''/home/www/test/'', type the following:
<?PHP
include_once "lib/codesgit/browse.php";
$options->limitAccess = "/home/www/test/";
$browse = new codesGit_browse($options);
?>
In this case the user can't access any folders above the directory 'test', he can just browse all files inside the directory 'test'.

denyAccess Option


This Option gives you the possibility to deny access to specific directories that you want to block.
For example:
If you want to block the access to the following directories on your wordpress script ("wp-includes", "wp-admin" and "wp-content"), type the following:
<?PHP
include_once "lib/codesgit/browse.php";
$options->denyAccess = array("/home/www/wp-includes/", "/home/www/wp-admin/", "/home/www/wp-content/");
$browse = new codesGit_browse($options);
?>

createDirs Option


This option allows the user to create new directories.
In TRUE case the user can create new directories
In False Case the user has no choice to create directories.
For example:
<?PHP
include_once "lib/codesgit/browse.php";
$options->createDirs = FALSE; //Deny users to create directories
$browse = new codesGit_browse($options);
?>

filesType Option


This option let you set specific files types as you want and contains of:
For example:
<?PHP
include_once "lib/codesgit/browse.php";
$options->filesType = "*.html"; //Show all HTML files
$browse = new codesGit_browse($options);
?>

deniedFilesType Option


This option let you set specific files types that you don't want them to appear and contains of:
For example:
<?PHP
include_once "lib/codesgit/browse.php";
$options->deniedFilesType = "*.html, *.txt"; //Hide all HTML and txt files
$browse = new codesGit_browse($options);
?>

themesPath Option


This option offers you the possibility to set the full path to the themes directory.
For example:
<?PHP
include_once "lib/codesgit/browse.php";
$options->themesPath = "http://www.example.com/test/themes/";
$browse = new codesGit_browse($options);
?>

selectedTheme Option


This option lets you set the selected theme name.
For example:
<?PHP
include_once "lib/codesgit/browse.php";
$options->selectedTheme = "my_custome_theme_name";
$browse = new codesGit_browse($options);
?>

view Option


This option gives you the liberty to control the view between grid or list.
- A sample for grid view:
-A sample for list view:
For example:
<?PHP
include_once "lib/codesgit/browse.php";
$options->view = "list";
$browse = new codesGit_browse($options);
?>

activeThumb - tempPath - siteTempPath Options


"activeThumb" option gives you the liberty to preview thumbnail for images.
"tempPath" is the full root path to "temp directory" where the thumbnail images will be saved.
"siteTempPath" is the full http path to "thumbnail images" directory for calling the thumbnail images.
For example:
<?PHP
include_once "lib/codesgit/browse.php";
$optns->activeThumb = TRUE;
$options->tempPath = "/home/www/test/_temp/";
$options->siteTempPath = "http://www.example.com/test/_temp/";
$browse = new codesGit_browse($options);
?>

A complete example 1


This is a detailed example illustrating how you can use the code with the following options:
<?PHP
include_once 'lib/codesgit/browse.php';
//options
$options1->view = 'grid';
$options1->activeThumb = TRUE;
$options1->filesType = '*.jpg;*.jpeg;*.png;*.gif'; //get all images
$options1->selectedTheme = 'blue';
$options1->createDirs = FALSE;

//call the class
$browse1 = new codesGit_browse($options1);

//the listener

if($_GET['browse1'] == "true")
{
    $browse1->listen();   
}
//The HTML Code
?>
<html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <?PHP
        $browse1->loadHeader();
        ?>
    </head>    
    <body>
         Please choose the file:<br>
         <input type="text" class="thePath" value="No File Selected" size="80" />
        <?PHP
        $browse1->create(".thePath", 'index.php?browse1=true', 'value="Select the Image..."');
        ?>
    </body>
</html>
Check the live demo here

A complete example 2


This is a detailed example illustrating how you can use the code with the following options:
<?PHP
include_once 'lib/codesgit/browse.php';
//options
$options2->view = 'list';
$options2->filesType = NULL; //hide all files and force user to select a directory
$options2->selectedTheme = 'default';
$options2->createDirs = TRUE;

//call the class
$browse2 = new codesGit_browse($options2);

//the listener

if($_GET['browse2'] == "true")
{
    $browse2->listen();   
}
//The HTML Code
?>
<html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <?PHP
        $browse2->loadHeader();
        ?>
    </head>    
    <body>
         Please select the directory:<br>
         <input type="text" class="thePath" value="No Directory Selected" size="80" />
        <?PHP
        $browse2->create(".thePath", 'index.php?browse2=true', 'value="Select Directory..."');
        ?>
    </body>
</html>
Check the live demo here