Gossamer Forum
Home : Products : Links 2.0 : Customization :

Report Deadlink

Quote Reply
Report Deadlink
Hello

Did I seek " Report Deadlinks " in Resource Center and didn't I find, will it be that am being blind? ; -)
If somebody can tell me where it is I thank.

Thank you

Adilson

Quote Reply
Re: Report Deadlink In reply to
I think that was made by Anthrotech and so it has been removed and won't be put back up again.

Problably shouldn't be too hard to make one that tells the webmaster the site.

The original had a feature which checks the link first before emailing which could be harder to include.



Glenn

Quote Reply
Re: Report Deadlink In reply to
Had a play around today and came up with something that works! Although it is fairly basic and so is probably missing some of the features of the other one.

This script will email you the deadlink site's id number, site name, url and tell you the url to go to check it and the url to type in to delete it. All the visitor does is click on report 'deadlink' next to a site. An email to the webmaster is sent and the visitor is redirected to a mail success page.

First copy the text below and save it as linkdead.cgi. Upload it to where your links cgi files are:



#!/usr/bin/perl
# -------------
# Links
# -------------
# Links Manager
#
# File: linkdead.cgi
# Notifies the webmaster of a deadlink
# Based on and designed to be used with
#Links 2 by: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 2.0
#
# (c) 1998 Gossamer Threads Inc.
#
# This script is not freeware! Please read the README for full details
# on registration and terms of use.
# =====================================================================
#
#
# Setup:
# Make sure the require statement below points to the config file.
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \

require "admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}

# ========================================================

eval { &main; }; # Trap any fatal errors so the program hopefully
if ($@) { &cgierr("fatal error: $@"); } # never produces that nasty 500 server error page.
exit; # There are only two exit calls in the script, here and in in &cgierr.

sub main {
# --------------------------------------------------------
# Sends an email to the admin, letting him know that there is a dead link.

my %in = &parse_form();

# Check to make sure that there is an admin email address defined.
$db_admin_email or &cgierr("Admin Email Address Not Defined in config file!");

my $to = $db_admin_email;
my $from = $in{$db_cols[$db_contact_email]};
my $subject = "Deadlink ID number: $in{'ID'}\n";
my $msg = qq|
The following link is reported to be dead:

ID number: $in{'ID'}
Site title: $in{'Title'}
Site URL: $in{'URL'}
Category: $in{'Category'}

To check the link, please go to:
$db_cgi_url/jump.cgi?ID=$in{'ID'}

Or to delete the link please go to:
$db_cgi_url/$db_script_path/admin.cgi?db=links&ID=$in{'ID'}&Title=&URL=&Date=&Category=---&Description=&Contact+Name=&Contact+Email=&Hits=&isNew=---&isPopular=---&Rating=&Votes=&ReceiveMail=---&Graphic=&Gwidth=&Gheight=&Priority=---&Password=&MonthHits=&isMonthPopular=---&DateAdded=&keyword=&mh=10&sb=---&so=ascend&delete_form=Search&delete=$in{'ID'}



Sincerely,

Visitor.
|;

# Then mail it away!
require "$db_lib_path/Mailer.pm";
my $mailer = new Mailer ( { smtp => $db_smtp_server,
sendmail => $db_mail_path,
from => $from,
subject => $subject,
to => $to,
msg => $msg,
log => $db_mailer_log
} ) or return;
$mailer->send or return;
print &site_html_deadlink_mail;
}



Next add the following to link.html

<a href="<%db_cgi_url%>/linkdead.cgi?ID=<%ID%>&URL=<%URL%>&Title=<%Title%>&Category=<%Category%>"> Report a deadlink</a>



Make a template called something like deadlinkmailed.html (this will be what the visitor will see after submitting a deadlink)

Then add a sub routine called:

sub site_html_deadlink_mail

into site_html_templates.pl and refer to deadlinkmailed.html

use something like below:

sub site_html_deadlink_mail {
# --------------------------------------------------------
# This routine determines how the deadlink mail success page will look like.
&html_print_headers();
print &load_template ('deadlinkmailed.html', {
%in,
%globals
});
}


That should do it. I've tested it on my site and so far it works fine.


Quote Reply
Re: Report Deadlink In reply to
i will maybe make one that looks a tad bit neater than that, and checks the site as you exclaimed before. Its not hard.

Quote Reply
Re: Report Deadlink In reply to
Yeah I have missed out a few other pieces above such as: returning an error page, including html headers and emailing the webmaster the site title and url as well. For me it's okay because I don't use headers and don't have LWP installed.

I've had links for some time but have never looked much at the code (infact any programming code) until about 2 weeks ago. So it's about time I started learning some!

After all the great usefull mods people like yourself have made I thought it's time I try and put somethings back in return. My ideas/solutions probably won't be great but I'll give it my best attempt!

Thanks for putting your mods backup again, I'm sure many more will find them usefull.

Cheers


Glenn


Quote Reply
Re: Report Deadlink In reply to
I've changed the dead link script so that it now sends admin the site's ID, url, name and the category it's in.

If anyone is interested in it I'll post the codes in a few days time.


Cheers

Glenn

Quote Reply
Re: Report Deadlink In reply to
Hello, thank you for the help.
Unhappily the script didn't work for me, I am trying to discover because.
He shows me the following message: " Admin Email Address Not Defined in config file "!, and the e-mail is configured correctly in the links.cfg, see:
$db_mail_path = ' /usr/sbin/sendmail ';
$db_admin_email = ' info@sextour.com.br ';
The stranger is that I am receiving the e-mails of the deadlink!!!!
Will it be that you could help me?

Thank you.

Quote Reply
Re: Report Deadlink In reply to
Very strange! Have you had any problems like that before with other scripts using the sendmail in links? Ie test the subscribe option and see what comes up.


As your sendmail is working I can suggest you do the following changes to the linkdead.cgi script:

Delete:

# Check to make sure that there is an admin email address defined.
$db_admin_email or &cgierr("Admin Email Address Not Defined in config file!");

Try deleting that part first and then test it.
If that doesn't work let us know cause I have another possible solution.


Glenn

Quote Reply
Re: Report Deadlink In reply to
Glen,

Thanks for taking the time to make this mod. I tried it also and got an 500 error. However, it did sent the email.

George

Quote Reply
Re: Report Deadlink In reply to
I tested it on mine and it works fine. I pretty certain the problem on yours is template related:

One thing that WILL give an error is if you use tags in the templates. ie. <html><head><body>etc... don't use any tags just put in a text message. The best thing to do is write a message in notepad and then save it as html. (using programs such as composer will automatically add tags in when you save it). I'll post some templates on my site tonight. Also I've altered the code slightly since the post above.


Glenn

Quote Reply
Re: Report Deadlink In reply to
Yep the I have placed the newer code and templates here for the deadlink mailer:

http://mir.spaceports.com/~glennu/

Just found out what was causing the 500 error problem. I hadn't included a piece of code in the sub deadlink_mail_success

sorry! Anyway here it is:

sub site_html_deadlink_mail {
# --------------------------------------------------------
# This routine determines how the deadlink mail success page will look like.
&html_print_headers();
print &load_template ('mailcomplete.html', {
%in,
%globals
});
}


Quote Reply
Re: Report Deadlink In reply to
Glen,

Awesome! Got it work! But one small problem. I am getting a
"1" in the mailcomplete.html. Now, I remember reading it somewhere but I am searched out Shocked and can't remember it.

Any suggestions?

Thanks

Also, I added:


sub site_html_deadlink_mail {
# --------------------------------------------------------
# This routine determines how the deadlink mail success page will look like.
&html_print_headers();
print &load_template ('mailcomplete.html', {
%in,
%globals
});
}

Above:

sub site_html_print_cat {

George


Quote Reply
Re: Report Deadlink In reply to
Yeah I got rid of it on my tell a friend script. I've had a quick go at getting rid of i on this script but haven't done it yet. I'm affraid I'll be very busy with work for the next 2 weeks but after that I'll be going back over all of the scripts.

I just hid it on mine for the moment by coloring the page black. (It's okay to use any tags no so you can customise it like an ordinary html page. Or if you want a different background colour use that and change the default text colour to what ever that bgcolour is.

Here's an example of wha I used. (I also used a back button)

<html>
<head>
<title>
Deadlink submitted to webmaster
</title>
</head>
<body bgcolor="000000">

<TABLE BORDER=0 CELLSPACING=4 CELLPADDING=4 COLS=1 WIDTH="100%" >
<TR>
<TD>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
<tr>
<td BGCOLOR="#993366">
<small class="menutitle">
<center>
The webmaster has been notified of the deadlink. Thank you
</center>
</td>

<td WIDTH="125" BGCOLOR="#993366">

</td>
</tr>
</table>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" HEIGHT="29" >
<tr>
<td WIDTH="90%" HEIGHT="13" BGCOLOR="#663366">
<center>
<form>
<input type=button value=" <- Back " onClick="history.go(-1)" style="background:=39265E" STYLE="color:99ff99">
</form>
</center>
</td>
</tr>
</table>
</TD>
</TR>
</TABLE>

</body>
</html>



Quote Reply
Re: Report Deadlink In reply to
Hey, it's working now!

Thanks, thanks, thanks ;-)

Adilson