Gossamer Forum
Home : Products : Links 2.0 : Customization :

Mod Idea - Auto Check for Duplicate URL

(Page 3 of 3)
> >
Quote Reply
Re: Mod Idea - Auto Check for Duplicate URL In reply to
Yes...act...

You need to use the following submit field in the modify.html file:

Code:
<input type="SUBMIT" name="submit_form" value="Modify Resource">

Then in the modify_error.html file, use the following submit field:

Code:
<input type="SUBMIT" name="submit_form" value="Modify Resource">

Then in the modify_confirm.html file, use the following submit field:

Code:
<input type="SUBMIT" name="process_form" value="Modify Resource">

Get it? I hope.

Wink

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: Mod Idea - Auto Check for Duplicate URL In reply to
Just a note to say thanks to Gerrit. Hope this lowers my stress level.

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Mod Idea - Auto Check for Duplicate URL In reply to
Hi!
any idea with this error
CGI ERROR
==========================================
Error Message : fatal error: Undefined subroutine &main::site_html_add_failure called at /cgi-bin/links/add.cgi line 102.

any help would be great..this error i get when i szubmitt a site that is already in DB

gregor


Quote Reply
Re: Mod Idea - Auto Check for Duplicate URL In reply to
hey everyone her is an idea from a previous mod:


Step 1



In db_utils.pl, at sub validate_record, right below this:

if ($rec{'add_record'}) { # don't need to worry about duplicate key if modifying
open (DB, "<$db_file_name") or &cgierr("error in validate_records. unable to open db file:$db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
($data[$db_key_pos] eq $rec{$db_key}) and return "duplicate key error";
}
close DB;
}

add this:

if ($rec{'add_record'}) { # don't need to worry about duplicate if modifying (unless, however, URL is changed!)
$testURL = $in{'URL'};
$testURL =~ tr/A-Z/a-z/;
$testURL =~ s/www\.//; # disregards www.
$testURL =~ s/\///g; # ignores slashes
$testURL =~ s/index\.html|index\.htm//; # disregards index.htm(l)
open (DB, "<$db_file_name") or &cgierr("error in validate_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
$dataURL = $data[$db_url];
$dataURL =~ tr/A-Z/a-z/;
$dataURL =~ s/www\.//; # disregards www.
$dataURL =~ s/\///g; # ignores slashes
$dataURL =~ s/index\.html|index\.htm//; # disregards index.htm(l)
if ($dataURL eq "$testURL") {push(@input_err, "duplicate URL error - already listed!");} # so let's add it as an error
}
close DB;
open (DB, "<$db_valid_name") or &cgierr("error in validate_records. unable to open db file: $db_valid_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
$dataURL = $data[$db_url];
$dataURL =~ tr/A-Z/a-z/;
$dataURL =~ s/www\.//; # disregards www.
$dataURL =~ s/\///g; # ignores slashes
$dataURL =~ s/index\.html|index\.htm//; # disregards index.htm(l)
if ($dataURL eq "$testURL") {push(@input_err, "duplicate URL error - already submitted!");} # so let's add it as an error
}
close DB;
}

Step 2a (for most users - skip this only if you use images for buttons)



If you don't use templates

In links_html.pl, at sub site_html_add_form, find:

<input type="SUBMIT" value="Add Resource">

change to:

<input type="SUBMIT" name="add_record" value="Add Resource">

at sub site_html_add_failure, find:

<input type="SUBMIT" value="Add Resource">

change to:

<input type="SUBMIT" name="add_record" value="Add Resource">



If you use templates

In both add.html and add_error.html, find:

<input type="SUBMIT" value="Add Resource">

change to:

<input type="SUBMIT" name="add_record" value="Add Resource">



Step 2b (only if you use images for buttons, skip otherwise)



If you use images for buttons (templates version):

in both add.html and add_error.html, find: (/images/submit.gif should be what you have for image path, and height="25" width="100" for your image's dimensions)

<input type="image" src="/images/submit.gif" height="25" width="100" border=0 alt="Submit">

add this right below or behind:

<input type="hidden" name="add_record" value="true">



If you use images for buttons (non-templates version):

In links_html.pl, in both sub site_html_add_form, and sub site_html_add_failure, find: (/images/submit.gif should be what you have for image path, and height="25" width="100" for your image's dimensions)

<input type="image" src="/images/submit.gif" height="25" width="100" border=0 alt="Submit">

add this right below or behind:

<input type="hidden" name="add_record" value="true">



Step 3



Save, upload, and you should be safe from most duplicate URL submissions.



Quote Reply
Re: Mod Idea - Auto Check for Duplicate URL In reply to
hi!
i think i found a bug..or i hope just my fault.
when i submit a site that is already in links it gives me add_error.html. so far ok...so this means he found in db so till here everything works...then i have chance to change the information submitted and resubmit. Aha here comes my problems. If i don't change anything and resubmit...THE SITE IS ADDED!
is this a bug or my fault..hope my :)

bye
thanx
gregor

Quote Reply
Re: Mod Idea - Auto Check for Duplicate URL In reply to
I have installed this mod and it is great , except that on my site I have quite a few entries that don't have URLS, how would I modify it so that it would allow these. Currently it considers them to be duplicates.

Thanks

Rob



Quote Reply
Re: [RobL] Mod Idea - Auto Check for Duplicate URL In reply to
Where in db_utils.pl do you insert the code?




***************************************************************
Add your site to my directory at XEVA Links.
***************************************************************
Quote Reply
Re: [PynApple] Mod Idea - Auto Check for Duplicate URL In reply to
It shows you where in the post above:
http://www.gossamer-threads.com/...i?post=107538#107538


Leonard
aka PerlFlunkie
> >