Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

MOD: Duplicate Submission Check

Quote Reply
MOD: Duplicate Submission Check
Please see the reply below by AnthroRules.

I have removed my MOD in preference to AnthroRules - his version uses much less code and is easier to implement.

See below ...

All the best
Shaun
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
I did this without creating those subroutines you are using.

Wink

Using the following codes in the sub process_form routine:

Code:


# Check that the record hasn't been added already in the Links and Validate tables.

$val = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Validate.def";
$val->query ( { Description => $in->param('Description'), URL => $in->param('URL'), Title => $in->param('Title'), ww => 1 } );
$db = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Links.def";
$db->query ( { Description => $in->param('Description'), Title => $in->param('Title'), URL => $in->param('URL'), ww => 1 } );
if (($db->hits) and ($val->hits)) {
&site_html_error ( { error => "A request to add this record has been received. We will notify you via email when your link has been validated."}, $dynamic);
return;
}
if ($db->hits) {
&site_html_error ( { error => "Your link already exists in our database. To modify your link, please click on the Edit Link link located at the top and bottom of our web pages."}, $dynamic);
return;
}
if ($val->hits) {
&site_html_error ( { error => "A request to add this record has been received and your link has not been validated yet."}, $dynamic);
return;
}


Regards,

Eliot Lee

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Eliot,

Thanks for the reply, your solution is much more elegant Smile and I've decided to use your version instead!

I'll leave my mod there for the time being just in case someone can make use of it in some way :)

All the best
Shaun

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
I don't know about more elegant...but it uses less codes.

And...you're welcome.

Regards,

Eliot Lee

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Hey quango,

This script is very useful to me. Thanks

I was wondering, is there a way to check for Contact_Email as well?? Only 1 e-mail per link?

I notice there is a bug as well, when you send without typing anything it will say, "link is in process of review"..

Is there a way to fix this?

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
In Reply To:
I was wondering, is there a way to check for Contact_Email as well?? Only 1 e-mail per link?
Yep...in the query statements, add:

Code:

Contact Email => $in->param('Contact Email'),


And about the bug you mentioned...I have not noticed that.

Regards,

Eliot Lee
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
mrcry11,

I haven't noticed the 'bug' you report, but I'm guessing that you don't have any required fields in your submission form, is that correct?

If your form does not require the URL or any of the other fields that you use to check waiting submissions, then it'll probably report the error by default. To stop this happening, just set the URL and in your case the Contact Email to be required by the form.


All the best
Shaun

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Hi Eliot,
your mod is very useful for me. In the sub process_form I have now:
# Connect to the database.
$val = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Validate.def";
# Check that the record hasn't been added already in the Links and Validate tables.
$val->query ( { Description => $in->param('Description'), URL => $in->param('URL'), Title => $in->param('Title'), ww => 1 } );
$db = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Links.def";
$db->query ( { Description => $in->param('Description'), Title => $in->param('Title'), URL => $in->param('URL'), ww => 1 } );
if (($db->hits) and ($val->hits)) {
&site_html_error ( { error => "A request to add this record has been received. We will notify you via email when your link has been validated."}, $dynamic);
return;
}
if ($db->hits) {
&site_html_error ( { error => "Your link already exists in our database. To modify your link, please click on the Edit Link link located at the top and bottom of our web pages."}, $dynamic);
return;
}
if ($val->hits) {
&site_html_error ( { error => "A request to add this record has been received and your link has not been validated yet."}, $dynamic);
return;
}

When I call now this add.cgi I get the following error:
Execution of add.cgi aborted due to compilation errors.

What have I done wrong? Please help.

Regards,

Wolfgang

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Please do either of the following:

1) Check your Perl Error Logs.

OR

2) Check the syntax of the add.cgi file. Don't know how to do that??? Search the support forums for check syntax telnet.

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Hi Eliot,
the error message is now:
"$db" requires explicit package name at add.cgi line 110.
What does this mean?

Regards,

Wolfgang

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
You need to localize the $db variable in the sub process_form by adding it in the my ($variable, $variable); code line OR add the $db in the following line of codes above the sub main routine:

Code:

use vars qw/%in/;


Like the following:

Code:

use vars qw/%in $db/;


OR simply add my before both $val and $db in the codes I provided above!

Got it?

Regards,

Eliot Lee
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
I'm kinda slow.. is this what you mean?

# Check to see if the URL already exists in the Validate or Links tables

my $url = $in->param('URL');
my $Contact_Email = $in->param('Contact Email');
my ($val_hit, $link_hit, $email_hit);

$val_hit = &check_url_val ($url);
if ($val_hit >= 1) {
&site_html_error ( { error => "<font color=blue>$url<p><p><b>The URL you suggested has already been suggested and is currently waiting for a site review.</b></font>", %in }, $dynamic);
return;
}

$link_hit = &check_url_link ($url);
if ($link_hit >= 1) {
&site_html_error ( { error => "<font color=blue>$url<p><p><b>The suggested URL already exists is our listings. You can type the site URL in the search box to find more details.</b></font>", %in }, $dynamic);
return;
}
$email_hit = &check_url_link ($Contact_Email);
if ($email_hit >= 1) {
&site_html_error ( { error => "<font color=blue>$Contact_Email<p><p><b>The suggested EMAIL already exists is our listings. You can type the site URL in the search box to find more details.</b></font>", %in }, $dynamic);
return;
}
}

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Welp since you are NOT using my modification, I will defer to qango since you are using HIS mod.

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
mrcry11,

As you'll see I've now removed my MOD from the top of this thread since it was much longer than it needed to be, and Eliots solution was better and easier to implement.

Sorry for the inconvenience, but I would advise you use your backup copies to return your files to their previous state and then try again using Eliots MOD code.

All the best
Shaun

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Elliot

I need to use your mod, to stop duplicate entries. However, I think something got deleted here.

What am I replacing here! Is it in the "add.cgi" then "sub process_form" then replace "# Check the referer." ??????????????

http://www.sfahq.com
Phil the FOG
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Did you not read my post????

In Reply To:

Using the following codes in the sub process_form routine:


Don't know how to make it clearer. Wink

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
I Replaced all under:

sub process_form {
# --------------------------------------------------------

I get ERROR when I try to Add Site.

http://www.sfahq.com
Phil the FOG
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
In Reply To:
I get ERROR when I try to Add Site.
And the Error is...???

It would help to post the EXACT error message you get and NOT the CGI.pm Software Error.

Check the syntax via telnet....

Code:

perl -c add.cgi


Then post the EXACT error message you receive and look through the previous messages in Threads as many bugs have already been addressed!

Regards,

Eliot Lee
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Eliot,

This lines work on Links SQL 2, I need to add duplicate link check on the new version of links.

I don't know why this feature is not build originaly on Links SQL 2, imagine a site like Yahoo without this feature, they could add and add a lot of duplicated links all time without knowing.

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Nope...the codes I provided only work in LINKS SQL v.1.X.

You will need to adjust the syntax to work with LINKS SQL v.2.X, which I have not spent enough time yet to give you code snippets that would work.

Regards,

Eliot Lee
Quote Reply
Re: MOD: Duplicate Submission Check In reply to
Do you know if some one can help me on this problem

Quote Reply
Re: MOD: Duplicate Submission Check In reply to
May be pugdog, the up and coming LINKS SQL v2.0 guru...hehe! Wink

Regards,

Eliot Lee