Gossamer Forum
Home : Products : Links 2.0 : Customization :

Only allowing links ending with .mp3 extension

Quote Reply
Only allowing links ending with .mp3 extension
Please help, I run a music directory which uses links and wish to only allow people to add direct links to music files and so was wondering if someone could tell me how to allow people to only submit links that ended with .mp3 or .wav

I suppose it would be similar to the mod banning certain URLs but its a bit different as I am allowing only 2 types of file extension!

Thankyou
From Paul Wilson.
Quote Reply
Re: Only allowing links ending with .mp3 extension In reply to
This is very easy. All you do is open your links.def file and edit this line:

Code:
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
to look like this:

Code:
URL => [2, 'alpha', 40, 75, 1, 'http://', '$mp3|wav'],
The caret (^) in the original line makes it impossible to submit a URL that doesn't begin in with one of the four strings separated by pipes (|). Likewise, the $ in the edited line stipulates that the URL must end with one of the legal strings that follows it.


Floristan

Quote Reply
Re: Only allowing links ending with .mp3 extension In reply to
Thanks very much!

Thankyou,
From Paul Wilson.
Quote Reply
Re: Only allowing links ending with .mp3 extension In reply to
You're welcome, Paul.

By the way, I have discovered a bug in Microsoft Internet Explorer for Macintosh versions 4.5 and 5.0 which will affect you. Those URLs ending in .wav and .mp3 are for downloadable files, right? Well, if someone visits your site using a Macintosh and MSIE and clicks on a link to a downloadable file which is passed through jump.cgi, the file will be saved to their hard drive with the name "jump.cgi" instead of "whatever.wav" or "whatever.mp3".

You could post direct URLs instead of passing them through jump.cgi, but then the hits won't be recorded and you will have no stats on how many downloads have occurred.

There is a very significant number of Macintosh users out there (especially since the introduction of the IMac), so I think this is of real concern to all Links users whose databases contain links to downloadable files.

I have come up with a solution which is not ideal, but I think it's the best thing possible since the bug lies in Microsoft's software and not GT's. I have written a JavaScript which detects the visitor's browser. If the browser is MSIE for Macintosh, the script then opens a small popup window which explains the bug and tells the visitor to rename any files they download. Netscape users and Windows IE users will never see this popup window.

Anyway, I have just written the script. After I test it a little, I will post it here and in the Resources section. You could help me out, Paul, by testing your site on a Mac using MSIE (if at all possible). I already know that MSIE 4.5 and 5.0 for Mac have this bug, but I haven't tested other versions of MSIE for Mac. If you, or anyone else, reports to me that other versions are affected, I will update my JavaScript to include those versions.

Thanks for any help you can provide.

Best wishes,
Floristan

Quote Reply
Re: Only allowing links ending with .mp3 extension In reply to
Excellent work!
Thanks for taking the time to tell me about the bug, and thanks for creating sort of a solution!

I dont have access to a Mac to be honest though! Only PCs with Windows installed - sorry!

When you finish testing your Javascript please could I have a copy as it may come in handy!



Thankyou,
From Paul Wilson.