Hi,
   
   May I know, how can I generalize my php script and how would that script be 
like based on these description and also the flow chart:
   
   1--The script should be a ONE php-program that takes a file name (URL) to 
download as command line parameter.
   
   2--Depending on the extension of the file to download, the program should 
choose between downloading and unpacking (.ext1 extension), or just downloading 
(.ext2 and .ext3).
   
   flowchart
     Code:
  
    .
    |
    |
---------------
|file extension|---ext1---set ext1=true----
---------------                           |
    |                                     |
    |ext2, ext3                           | 
    |                                     |
---------------                           |
|set ext1=false|                          |
---------------                           |
    |                                     |
    |--------------------------------------
    |
--------------
|download     |
--------------
    |
    |
    |
--------                ---------
|ext1   |------true----- unzip  |
--------                ---------
    |                      | 
    |                      |
    |                      | 
 false                   ready
 
  
   1. Get the file name from the URL, using $_GET I presume. If there isn't 
one, give an error and quit.
   2. Make sure the file exists in the directory it should exist in. If not, 
give an error and quit.
   3. Find the extension: strrchr would be useful.
   4. Determine your action based on the extension.
   5. Carry out the action.
   
   How can I proceed by including all the necessary functions to make it 
work????? your help is appreciated.!!!! thanks....
   
   I have started to draft out as follows:
   Pseudo-code
     Code:
  
<?php

if (there is NOT a file provided) {
    print a message about how the filename is missing
    quit
}

get the name of file
get the extension of the file
if (the extension is "ext1") {
    set $ext1 to true
} else {
    set $ext2 to false
}

if ($ext1) {
    unzip the file to some temporary location
    send a header saying "the file is this-many bytes in size"
    send a header saying "the browser should download this, not display it"
    read the contents of the temporary file and send it directly to the browser
} else {
    send a header saying "the file is this-many bytes in size"
    send a header saying "the browser should download this, not display it"
    read the contents of the file and send it directly to the browser
}

?>
 
  
       
---------------------------------
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot 
with the All-new Yahoo! Mail  

[Non-text portions of this message have been removed]

Reply via email to