Get IP Address Determines a users IP address.Implementation: AMFPHPDate Added: 2003-11-22
|
| Service Author: |
Jeffrey Hill |
| Implementation: |
AMFPHP version: .9 |
A file/directory browser that allows you to easily navigate through your file system in flash. |
|
|
|
|
With this service you can navigate through your file system. It use's an extended flash listbox to graphically show files and folders. You can click on a folder to view the contents of that folder. The file name, file size, and last modified date are returned as an array to the flash client via flash remoting.
|
|
*** If you are concerned with security, be sure to hardcode the directory path you wish to use as your base in the server code. ***
To use: Add the service code to your services directory. Download the sample fla file and change the path to your gateway. Set the directory path your wish to browse - and that's about it.
|
|
<?php
/*
* Simple Flash Directory Browser
* Inputs - this script expects a directory path as input, you can then view all sub directories and files.
* Author: Jeffrey Hill
* Site: www.flash-db.com/remoting/
*/
class directoryBrowse
{
function directoryBrowse()
{
$this->methodTable = array (
"browseDirectory" => array (
"description" => "Returns a list of all files in a directory, and allows to browse lower directories",
"access" => "remote",
"arguments" => array ("directory")
)
);
}
function browseDirectory($directory) {
// Hard code the base $directory variable here, if you are concerned about this service and security. (In the flash movie set the initial directory to "")
// $directory = "../../SomeDirectory/";
// Create List of Files and directories
// open up file directory.
if (is_dir($directory)) {
if ($dh = opendir($directory)) {
$i = 0;
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != "..") {
// returns the file description - ie file, dir, char, etc.
$temp["fileType"][$i] = filetype($directory . $file);
// returns the file name as an array.
$temp["fileName"][$i] = $file;
// Returns last modified Time
$temp["fileDate"][$i] = date("n/d/y g:i a", filemtime($directory."/".$file));
// returns the file size as an array.
$temp["fileSize"][$i] = filesize($directory . $file);
$i++;
}
}
closedir($dh);
// returns an array of file names and types
return $temp;
} else {
// return an error if the directory could not be opened.
return 'There was an error when trying to open the specified directory ('.$directory.') .';
}
} else {
// adds some error handling if the directory can not be located.
return 'The Directory was not found ('.$directory.'). Please check the directory path.';
}
}
}
?>
|
|
/* This uses a custom component, download the source files at the bottom to get the component */
#include "NetServices.as"
#include "NetDebug.as"
myResult = new Object();
myResult.onResult = function(result){
dirBox.removeAll();
for (i=(result.fileSize.length-1);i>=0;i--) {
fileName = result.fileName[i];
fileSize = result.fileSize[i];
fileDate = result.fileDate[i];
fileType = result.fileType[i];
// Configure Data Provider for Custom List Box
var directoryData = { fileName:fileName,fileSize:fileSize,fileDate:fileDate,fileType:fileType };
// Add Items to the custom list Box
dirBox.addItem(fileName, directoryData);
}
//dirBox.setChangeHandler("doSomethingWithSelectedFile");
}
myResult.onStatus = function(status){
trace("Error: " + status.description);
}
System.onStatus = myResult.onStatus;
// Create a connection to your gateway.
var conn = NetServices.createGatewayConnection("http:// pathTo /gateway.php");
// Specify the service you want to use. There has to be a file called 'filebrowse.php' in your
// services directory.
var myService = conn.getService("directoryBrowse", myResult);
// Set up the base directory. This is the directory where you start browsing from. It is relative from the
// flashservices directory.
var directory = "../../SomeDirectory/";
var parentDir = directory;
var currentDir = directory;
// Call the service. Load the initial directory map.
myService.browseDirectory(directory);
// Function used for browsing lower directory's.
function browseChild(dir) {
// dir is passed in from a button in the component.
childDir = currentDir+dir+"/";
// Call the service.
myService.browseDirectory(childDir);
parentDir = directory;
currentDir = childDir;
}
// used to browse parent directories.
function browseParent() {
currentDir = parentDir;
// Call the service. Pass in the parent directory.
myService.browseDirectory(parentDir);
}
|
download source files
|
Click on area link next to down arrow to expand area.
|