PHP
  Home arrow PHP arrow Page 7 - Stream Me Up, Scotty! (part 1)
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Stream Me Up, Scotty! (part 1)
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2000-11-07


    Table of Contents:
  • Stream Me Up, Scotty! (part 1)
  • Out With The Old...
  • ...In With The New
  • Where Am I?
  • GETting It Right
  • Start Me Up!
  • Lights! Camera! Action!
  • Well-Formed Ideas
  • Appendix: Code Listing

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Stream Me Up, Scotty! (part 1) - Lights! Camera! Action!
    ( Page 7 of 9 )

    The primary workhorse of the application is the file "actions.php4", which is reproduced below:

    <html> <head> <basefont face=Arial> </head> <body> <!-- the include.php4 interface will be inserted into this page --> <? // check for valid form entries else print error if (!$server || !$username || !$password) { echo "Form data incomplete!"; } else { // keep reading } ?> </body> </html>
    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:

    <? // action: change directory if ($action == "CWD") { // script code } // action: delete file(s) else if ($action == "Delete") { // script code } // action: download files else if ($action == "Download") { // script code } // action: upload file else if ($action == "Upload") { // script code } ?>
    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:

    connect to the FTP server and log in through the user-defined function connect(); change to the appropriate directory; perform the selected action; refresh the list of available files to reflect changes; display the file list and control buttons through the include()d file "include.php4"; close the FTP connection.
    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.

     
     
    >>> More PHP Articles          >>> More By Vikram Vaswani, (c) Melonfire
     

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek