Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    generalized php script...

    Hi all,

    May I know, how can I generalize my php script and how would that script be like based on these description:

    1--The new 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).

    How would I proceed in scripting the php then ? is there anywhere i could get a sample code working as described here????
    How to proceed with the coding with respect to the flowchart...?

    overall working flowchart.....

    Code:
        .
        |
        |
    ---------------
    |file extension|---ext1---set ext1=true----
    ---------------                           |
        |                                     |
        |ext2, ext3                           | 
        |                                     |
    ---------------                           |
    |set ext1=false|                          |
    ---------------                           |
        |                                     |
        |--------------------------------------
        |
    --------------
    |download     |
    --------------
        |
        |
        |
    --------                ---------
    |ext1   |------true----- unzip  |
    --------                ---------
        |                      | 
        |                      |
        |                      | 
     false                   ready
    Last edited by heroine; 09-06-2007 at 12:50 AM.

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    If you can get that flow diagram working I may be able to help.
    Ps try nesting it in the [QUOTE] tags
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    New to the CF scene
    Join Date
    May 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have started developing the script.....
    I want the user, once connected to the URL, to have the options to choose from: gz,txt and rdf extensions.

    If gz---> unzip first and then download
    if txt---> download.

    Is it also possible to be prompted to user the different specific filenames to be downloaded?
    hopefully i am on the right track....how to make this script work?

    Code:
    <?php
    $in=fopen($infile,"http://rdf.dmoz.org/rdf/") or die("cannot open $infile - does the file exist and is is allow_url_fopen on?\n");
    
    $out=fopen($outfile,"http://rdf.dmoz.org/rdf/") or die("cannot write to $outfile - problem with permissions?\n");
    
    while (!feof($in)) fwrite($out,fgets($in,1024));
    
    fclose($out);
    fclose($in);
    
    die("File does not exist."); // exit() also works
    
    if (empty($_GET["file"])) {
      // ...
    }
    
    $filename = 'test.php';
    if (strrchr($filename, ".") == ".gz") { 
     // ...
    	}
    header("Content-Length: " . filesize($filepath));
    
    	$fp = fopen($filepath, "r");
    	fpassthru($fp);
    	// or...
    	echo file_get_contents($filepath);
    ?>

  • #4
    New to the CF scene
    Join Date
    May 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please help needed for this script....

    what should I add or remove so that the script works fine....???
    plzzzzz help--.
    thanks

  • #5
    New to the CF scene
    Join Date
    May 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have made some changes here and there but still it isn't working.....

    am i missing something here?
    your help is appreciated...

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Post what you have.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •