Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

"report a bad link" plugin...

Quote Reply
"report a bad link" plugin...
Hi,

I installed and test bad_link. I want that only registered users may report a bad link. There are too many people who push the button for a joke!

Thanks,
Ron
Quote Reply
Re: [rsahertian] "report a bad link" plugin... In reply to
Just below Id checking bit, add something like this;

if (!$USER) { print Links::SiteHTML::display( 'error', { error => "You need to be logged in to use this function...." } ); exit; }

I don't have a copy of this on my PC, so I'm afraid I can't actually look at it in more depth, sorry.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] "report a bad link" plugin... In reply to
Gives me an error, so I commented it out.
Did I placed it well?

Thanks Andy,

ron...

****************************************



#!/usr/bin/perl
# ==============================================================
#
# Report a bad link version '2.1.1a'
# Links SQL code copyright Gossamer Threads
# http://www.gossamer-threads.com
# Modifications and code segments copyright PUGDOG Enterprises, Inc.
# http://www.pugdog.com
# Updates for Links SQL 2.1.1 Compatiblity by Andy
# http://www.ace-installer.com
#
# ==============================================================

# Load required modules.
# ---------------------------------------------------
use strict;
use Links::SiteHTML;
use Links::Authenticate;
use Links::Plugins;
use vars qw/$BAD_LINK_CFG/;

# use GT::Plugins qw/STOP CONTINUE/;
# use GT::Mail;
# $|++;
# Links::reset_env( { load_user => 1 } ) if ($Links::PERSIST);

local $SIG{__DIE__} = \&Links::fatal;

Links::init('/var/www/html/cgi-bin/lsql2/admin');
Links::init_user();



&main();

sub main {

# Define the variables
# ---------------------------------------------------
my ($id, $db_links, $rec, $confirm);

# Get the Links ID number from the input.
$id = $IN->param('ID');
$confirm = $IN->param('confirm');
print Links::SiteHTML::display('error', {error => "Invalid id: $id"});
return;
}
## Check to see if the ID/Link record exists

$db_links = $DB->table('Links'); ## first grab a new db handle

$rec = $db_links->get ($id); ## see if the ID record exists
print $IN->header();
return;
}

print "The ID was found, the rec is ", %$rec, "<br><BR>";

##############check user############
#if (!$USER) { print Links::SiteHTML::display ('error', { error => "LOG IN" }); exit; }
##################################
## Only waste the CPU after we've got a good link in the Links database.
##
## Need to put the configuration variables into the $CFG hash, or similar, and then
## they are globally available, and can be assigned/passed in a hash between routines.
## Works with persistence -- mod_perl speedyCGI, etc

$BAD_LINK_CFG = Links::Plugins::get_plugin_user_cfg ('Bad_Link');
my $bad_links_table = $BAD_LINK_CFG->{'table_name'};

# now, see if the record exists in the Bad_Links database

my $db_bad_links = $DB->table($bad_links_table);
my $rec2 = $db_bad_links->get ($id);
my $dynamic;

if ($db_bad_links->hits) {
$rec->{'Status'} = qq|
Thank you for taking the time to report the link <B>$rec->{'
Title'}</B> <P>\n
It's already been recorded, and and it's status is: &nbsp;<B
>$rec2->{'Status'}</B>
|;

print $IN->header();
print Links::SiteHTML::display ('bad_link', $rec );
return;

} else {
$rec->{'Status'} = qq|
Thank you for taking the time to report the link <B>
$rec->{'Title'}</B> <P>\n
It's been recorded, and will be checked ASAP
|;

$rec->{'Title'} =~ s/'/\\'/g;
$rec->{'Title'} =~ s/"/\\"/g;

$db_bad_links->add ( { LinkID => $id,
URL => $rec->{'UR
L'},
Title => $rec->{'Ti
tle'},
IP => $ENV{'REMO
TE_ADDR'}
} );

print $IN->header();
print Links::SiteHTML::display ('bad_link', $rec );
return;
}

} ## end of main
Quote Reply
Re: [rsahertian] "report a bad link" plugin... In reply to
Try replacing the top of the script, down to just before;

Code:
sub main {


.. and change it to;

Code:
#!/usr/bin/perl
# ==============================================================
#
# Report a bad link version '2.1.1a'
# Links SQL code copyright Gossamer Threads
# http://www.gossamer-threads.com
# Modifications and code segments copyright PUGDOG Enterprises, Inc.
# http://www.pugdog.com
# Updates for Links SQL 2.1.1 Compatiblity by Andy
# http://www.ace-installer.com
#
# ==============================================================

# Load required modules.
# ---------------------------------------------------
use lib '/path/to/your/admin/folder';
use Links qw/$IN $DB $CFG $USER/;
use strict;
use Links::SiteHTML;
use Links::Authenticate;
use Links::Plugins;
use vars qw/$BAD_LINK_CFG/;
use CGI::Carp qw(fatalsToBrowser);

local $SIG{__DIE__} = \&Links::fatal;

Links::init('/path/to/your/admin/folder');
Links::init_user();

# make sure they are logged in....you can comment out the next 4 lines if you don't mind them not being logged in...
if (!$USER) {
print $IN->header();
print Links::SiteHTML::display( 'error', { error => "You need to be logged in to use this function...." } );
exit;
}

# lets initiate it...
&main;

You need to change the 2 instances of /path/to/your/admin/folder to your path.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Sep 11, 2003, 3:06 AM
Quote Reply
Re: [Andy] "report a bad link" plugin... In reply to
Andy,

No error anymory, but I still can report a bad link when I am logged out!

thanks,
Ron

*******************************


#!/usr/bin/perl
# ==============================================================
#
# Report a bad link version '2.1.1a'
# Links SQL code copyright Gossamer Threads
# http://www.gossamer-threads.com
# Modifications and code segments copyright PUGDOG Enterprises, Inc.
# http://www.pugdog.com
# Updates for Links SQL 2.1.1 Compatiblity by Andy
# http://www.ace-installer.com
#
# ==============================================================

# Load required modules.
# ---------------------------------------------------
use strict;
use lib '/var/www/html/cgi-bin/lsql2/admin'; ## you need to set this to y
use Links::Authenticate;
use Links::Plugins;
use vars qw/$BAD_LINK_CFG/;

# $|++;
# Links::reset_env( { load_user => 1 } ) if ($Links::PERSIST);

local $SIG{__DIE__} = \&Links::fatal;

Links::init('/var/www/html/cgi-bin/lsql2/admin');
Links::init_user();



&main();

##make sure they are logged in
if (!$USER) {
print $IN->header();
print Links::SiteHTML::display( 'error', { error => "login first"} );
exit;
}

"bad_link.cgi" [readonly] 127L, 3891C
sub main {

# Define the variables
# ---------------------------------------------------
my ($id, $db_links, $rec, $confirm);

# Get the Links ID number from the input.
$id = $IN->param('ID');
$confirm = $IN->param('confirm');
print Links::SiteHTML::display('error', {error => "Invalid id: $id"});
return;
}
## Check to see if the ID/Link record exists

$db_links = $DB->table('Links'); ## first grab a new db handle

$rec = $db_links->get ($id); ## see if the ID record exists
print $IN->header();
return;
}

print "The ID was found, the rec is ", %$rec, "<br><BR>";

#if (!$USER) { print Links::SiteHTML::display ('error', { error => "login" }); exit; }
## Only waste the CPU after we've got a good link in the Links database.
##
## Need to put the configuration variables into the $CFG hash, or similar, and then
## they are globally available, and can be assigned/passed in a hash between routines.
## Works with persistence -- mod_perl speedyCGI, etc

$BAD_LINK_CFG = Links::Plugins::get_plugin_user_cfg ('Bad_Link');
my $bad_links_table = $BAD_LINK_CFG->{'table_name'};

# now, see if the record exists in the Bad_Links database

my $db_bad_links = $DB->table($bad_links_table);
my $rec2 = $db_bad_links->get ($id);
my $dynamic;

if ($db_bad_links->hits) {
$rec->{'Status'} = qq|
Thank you for taking the time to report the link <B>$rec->{'
Title'}</B> <P>\n
It's already been recorded, and and it's status is: &nbsp;<B
>$rec2->{'Status'}</B>
|;

print $IN->header();
print Links::SiteHTML::display ('bad_link', $rec );
return;

} else {
$rec->{'Status'} = qq|
Thank you for taking the time to report the link <B>
$rec->{'Title'}</B> <P>\n
It's been recorded, and will be checked ASAP
|;

$rec->{'Title'} =~ s/'/\\'/g;
$rec->{'Title'} =~ s/"/\\"/g;

$db_bad_links->add ( { LinkID => $id,
URL => $rec->{'UR
L'},
Title => $rec->{'Ti
tle'},
IP => $ENV{'REMO
TE_ADDR'}
} );

print $IN->header();
print Links::SiteHTML::display ('bad_link', $rec );
return;
}

} ## end of main
Quote Reply
Re: [rsahertian] "report a bad link" plugin... In reply to
Well, thats cos you didn't do what I asked you ;) I said to replace the WHOLE header ... there are more module includes, and cleaner coding stuff here.. thats why its not working!

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] "report a bad link" plugin... In reply to
Ok, ok sorry for that, I have to use the VI editor, otherwise I screwed up more. And I am not used to work with VI....

Gonna do it again.

UnsureBlush
Quote Reply
Re: [rsahertian] "report a bad link" plugin... In reply to
Works....!

Gonna read more careful in the future....

Thanks again Andy,

Ron
Wink
Quote Reply
Re: [Andy] "report a bad link" plugin... In reply to
>> there are more module includes, and cleaner coding stuff here.. thats why its not working!


Yeah, this was a real hack, and some of the problems have been discussed in other threads. Might want to search for them. There were suggestions on how to prevent robots from clicking, and such.

Also, this was put together for links 1.1, and a lot has changed through 2.12. We've all become better programmers, and Links itself is cleaner, and much more modularized.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] "report a bad link" plugin... In reply to
May want to add this into the main version pugdog. Maybe an option, and then something like;

if (!$USER && $CheckLoggedIn) {
...etc
}

?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [pugdog] "report a bad link" plugin... In reply to
In Reply To:
>> there are more module includes, and cleaner coding stuff here.. thats why its not working!


Yeah, this was a real hack, and some of the problems have been discussed in other threads. Might want to search for them. There were suggestions on how to prevent robots from clicking, and such.

Also, this was put together for links 1.1, and a lot has changed through 2.12. We've all become better programmers, and Links itself is cleaner, and much more modularized.


Is this supposed to work at all? There's no way to purge an individual bad link!