New/Top 10 files?

Here's a place to suggest/discuss improvements to the site.

Moderator: HypnoEMG

New/Top 10 files?

Postby iamstretchypanda » January 7th, 2007, 1:16 am

Any idea why the NEW - Top10 files want to load into my web browser and the files on the files section want to download? (note: I can download all the top 10 files from the files section

I tried right clicking a New - Top10 file and clicking 'save link as' in firefox 2. It saved the file as a php file, but would not open on my computer (note that i do have apache and php5 installed). Now when i left-clicked the same file in the same New- Top10 section, it opened it inside the webbrowser, but the extension on the page was .mp3

IE7 had no problem. It must just be a firefox rendering thing. Any idea of a setting i can change to fix that? (its not a big deal)
'Saying Java is nice because it works on all OS's is like saying that anal sex is nice because it works on all genders.'

'Mary had a little lamb, the doctor was surprised. When Old McDonald had a farm, the poor guy nearly died.'
iamstretchypanda
Regular
Regular
 
Posts: 24
Joined: December 27th, 2006, 1:00 am

Re: New/Top 10 files?

Postby homerj1620 » February 14th, 2007, 4:14 pm

[quote:dd8ad2c959="iamstretchypanda"]I tried right clicking a New - Top10 file and clicking 'save link as' in firefox 2. It saved the file as a php file, but would not open on my computer (note that i do have apache and php5 installed). Now when i left-clicked the same file in the same New- Top10 section, it opened it inside the webbrowser, but the extension on the page was .mp3[/quote:dd8ad2c959]

Don't right click. Do a left click and it will prompt you to download, with the correct file name. If you get a file with the .php extension rename it to .mp3.

One thing that would be nice is if EMG changed the way downloads are handled.

For example, you could create a download script named "download". The download link would go to, say, hypnofiles.com/download/TheFile.mp3

In the server configuration (Apache) just use:

[code:1:dd8ad2c959]<Files download>
SetHandler application/x-httpd-php
</Files>[/code:1:dd8ad2c959]

To actually get the values passed, use something like this:

[code:1:dd8ad2c959]// Get the everything that was passed to the script
$request_string = ereg_replace($_SERVER['SCRIPT_NAME'], "", $_SERVER['REQUEST_URI']);

// Split the values into an array
$args = explode ("/", $request_string);

// Set the name of the file
if (preg_match("/^\w{1,30}\.mp3$/", $args[1]) {
// Set it
$file = $args[1];
}
else {
// The file the user passed isn't valid
// Must be between 1 and 30 letters/numbers with a .mp3 extension
$file = "";
// I'd usually throw an exception here and have the caller display an
// error
}[/code:1:dd8ad2c959]

Then from there you can check the access and send the user the file.

You can also pass other values, say you wanted to have value hash (SHA-1, use the sha1() function) before each download. Example:

/download/15e7e6e56fb2f487ae1036afda2540997e9bb43b/TheFile.mp3

"TheFile.mp3" is now $args[2]. Things would now look like this:

[code:1:dd8ad2c959]// Check the hash
if (preg_match("/^[0-9a-f]{40}$/", $args[1]) {
// Set it
$hash = $args[1];
}
else {
// The hash isn't valid.
$hash = "";
// I'd usually throw an exception here and have the caller display an
// error
}

// Get the name of the file
if (preg_match("/^\w{1,30}\.mp3$/", $args[2]) {
// Set it
$file = $args[2];
}
else {
// The file the user passed isn't valid
// Must be between 1 and 30 letters/numbers with a .mp3 extension
$file = "";
// I'd usually throw an exception here and have the caller display an
// error
}[/code:1:dd8ad2c959]

Just a thought. I do something similar to display generated PDFs to users.
homerj1620
Newbie
Newbie
 
Posts: 2
Joined: December 21st, 2006, 1:00 am


Return to Site Improvements

Who is online

Users browsing this forum: No registered users and 0 guests

cron