...

View Full Version : generalized php script...



heroine
09-05-2007, 12:36 PM
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.....



.
|
|
---------------
|file extension|---ext1---set ext1=true----
--------------- |
| |
|ext2, ext3 |
| |
--------------- |
|set ext1=false| |
--------------- |
| |
|--------------------------------------
|
--------------
|download |
--------------
|
|
|
-------- ---------
|ext1 |------true----- unzip |
-------- ---------
| |
| |
| |
false ready

timgolding
09-05-2007, 01:21 PM
If you can get that flow diagram working I may be able to help.
Ps try nesting it in the [QUOTE] tags

heroine
09-07-2007, 07:01 PM
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?



<?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);
?>

heroine
09-09-2007, 01:47 PM
Please help needed for this script....

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

heroine
09-13-2007, 02:24 AM
I have made some changes here and there but still it isn't working.....

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

Inigoesdr
09-13-2007, 02:30 AM
Post what you have.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum