The primary workhorse of the application is the file "actions.php4", which is reproduced below: Right up front, "actions.php4" checks if the various form variables exist - if not, it simply prints an error message. If the variables exist, the script will proceed to the "else" clause of the conditional statement. Next come the various "actions". This script has been built to allow the following types of actions: "action=CWD" change working directory "action=Delete" delete selected file(s) "action=Download" download selected file(s) "action=Upload" upload selected file If you take a look at the file "include.php4", which contains the HTML interface, you'll see that it consists of a number of forms, each one linked to a specific function. Each of these forms contains a field (usually hidden) which specifies the action to be taken when that specific form is submitted. For example, the button marked "Delete", when clicked, sends the directive "action=Delete" to the PHP script "actions.php4", while the button "Go" sends the directive "action=CWD" to the script. In order to handle these four actions, the meat of "actions.php4" is a set of branching conditional statements, like this: Each of these branches includes code to connect to the FTP server, perform the selected action and exit. Typically, this code follows a simple progression: These sections are commented liberally in the code listing which follows. Some points to be noted here: The actions that deal with multiple files - namely, "action=Delete" and "action=Download" - use "for" loops to iterate through the array of selected files and delete or download each of them. The variables $cdir and $here are refreshed at each stage to indicate the current directory. This article copyright Melonfire 2000. All rights reserved.
blog comments powered by Disqus |
|
|
|
|
|
|
|