Gossamer Forum
Home : Products : Links 2.0 : Customization :

Mod to fix URL's

Quote Reply
Mod to fix URL's
Folks:

I've just created a mod that will FIX bad URL's when they are added.

A bad URL is defined as anything that does NOT have a protocal prefix (http://, ftp://, telnet:, news:, etc).

It's added to the add.pl command in the main directory...

Here's the context that the code should be added...
# Update the counter.
open (ID, ">$db_links_id_file_name") or &cgierr("error in get_defaults. unable to open id file: $db_links_id_file_name. Reason: $!");
flock(ID, $LOCK_EX) unless (!$db_use_flock);
print ID $in{'ID'}; # update counter.
close ID; # automatically removes file lock

# David's mod start's here...
# Append http:// if there is no protocal specified on the addition.
if (!($in{'URL'} =~ /:/)) {
$in{'URL'} = "http://" . $in{'URL'};
}
# David's mod end's here...

# Print out the validate input to a "validation database" where it is stored until
# the admin decides to add it into the real database.

If you have any questions, feel free to email me.

david
Quote Reply
Re: Mod to fix URL's In reply to
Hi David,

nice and useful. Thanks a lot. Works very well.

Take care

Michael

Quote Reply
Re: Mod to fix URL's In reply to
Except you're not taking into account the fact that Alex specifically designed links to NOT require a URL in there. This was so that people could list information, but not necessarly provide a url to a site. That was a feature than many people asked for, so Alex added it in.

--mark

------------------
You can reach me by ICQ at UIN #8602162


Quote Reply
Re: Mod to fix URL's In reply to
Well, the field is called "URL", and it *IS* required... so I guess the solution would be to not apply the mod? Won't hurt my feelings.

For me, the mod saved a lot of work... and wasn't hard to implement.

[This message has been edited by David_Gibbs (edited December 06, 1998).]