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

Password Reminder

Quote Reply
Password Reminder
Has anyone create a mod for Password Reminder with Links SQL ?

Quote Reply
Re: Password Reminder In reply to
Yes, try the following code in password.cgi:

Code:
#!/usr/bin/perl
# ==============================================================
# -------------
# Links SQL
# -------------
# Links Manager
#
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 1.11
#
# COPYRIGHT NOTICE:
#
# Copyright 1999 Gossamer Threads Inc. All Rights Reserved.
# No redistribution of this script may be made without prior
# written consent.
#
# By using this program you agree to indemnify Gossamer Threads
# Inc. from any liability.
#
# Please see the README for full license details.
#
# password.cgi done by emmerich@adeva.de for Links SQl 1.1
# ==============================================================

# Load required modules.
# ---------------------------------------------------
use strict;
use vars qw/%in/;
use CGI ();
use CGI::Carp qw/fatalsToBrowser/;
use lib 'admin';
use Links;
use Links::DB_Utils;
use Links::HTML_Templates;
use Links::DBSQL;
$|++;

&main();

sub main {
# --------------------------------------------------------

my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;
%in = %{&cgi_to_hash($in)};
print $in->header('text/html');

if ($in->param('sendto')) {

# Varible passed from the form
&process_form ($in, $dynamic);
}
else
{
&site_html_error ( { error => "Falscher Aufruf!" }, $dynamic);
}
}

sub process_form {
my ($in, $dynamic) = @_;
my ($db, $links);

# Make sure we have an email address to send the info to
if (!$in->param('sendto')) {
&site_html_error ( { error => "Bitte springen Sie zurück und geben eine E-Mail-Adresse ein!\n" }, $dynamic);
}
else
{
$db = new Links::DBSQL "$LINKS{admin_root_path}/defs/Links.def";
$links = $db->query ( { Contact_Email => $in->param('sendto'), ww => 1 } );

if ($links) {

# Check to make sure that there is an admin email address defined.
$LINKS{db_admin_email} or die ("Admin Email Address Not Defined in config file!");
my ($to, $from, $subject, $msg, $mailer);
$to = $in->param('sendto');
$from = $LINKS{db_admin_email};
$subject = "Anfrage\n";

$msg = "Sie haben folgende Einträge auf xxx eingestellt:\n\n";

my ($ID,$Password,$Titel);

foreach my $hit (@$links) {
$hit = $db->array_to_hash ($hit);
$ID = $hit->{'ID'};
$Titel = $hit->{'Title'};
$Password = $hit->{'Password'};


$msg = $msg ."------------------------------------------------------\nTitel: $Titel\nID: $ID\nPasswort: $Password\n\n\n";
}

$msg = $msg ."\nMit freundlichen Grüßen\n\nIhr Phoning Team \n\n__________________________________\nEinfach schärfer surfen mit\nhttp://www.xxxx.de\n";
#




# Then mail it away!
require Links::Mailer;
$mailer = new Links::Mailer ( {
smtp => $LINKS{db_smtp_server},
sendmail => $LINKS{db_mail_path},
from => $from,
subject => $subject,
to => $to,
msg => $msg
} ) or die $Links::Mailer::error;
$mailer->send or die $Links::Mailer::error;






&site_html_error ( { error => "Daten wurden verschickt!\n" }, $dynamic);
}
else
{
&site_html_error ( { error => "Diese E-Mail-Adresse ist dem System nicht bekannt!\n" }, $dynamic);
}
}
}
and do some fields in the template you want it:

Code:
<form action="http://xxx.xxx.xxx.xxx/cgi-bin/hwf_links/password.cgi" method="POST" name="">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" width="400"><TR><TD class=blb width="150" bgcolor="#D5D5D5">Mail-Adresse:</TD><TD width="250" bgcolor="#E3E3E3"><INPUT TYPE="text" NAME="sendto" SIZE="20"></TD></TR><TR><TD></TD><TD> </TD></TR><TR><TD>
<input type="Submit" value="Senden"></TD><TD> </TD></TR></TABLE></form>
Robert

Maybe some faults in html cause copied only a part of the whole page.
Quote Reply
Re: Password Reminder In reply to
Sorry, my mistake, what I meant is the password in Users table.

OK, I have this code :

#!/usr/bin/perl
# ==============================================================
# -------------
# Links SQL
# -------------
# Links Manager
#
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 1.11
#
# COPYRIGHT NOTICE:
#
# Copyright 1999 Gossamer Threads Inc. All Rights Reserved.
# No redistribution of this script may be made without prior
# written consent.
#
# By using this program you agree to indemnify Gossamer Threads
# Inc. from any liability.
#
# Please see the README for full license details.
#
# ==============================================================

# Load required modules.
# ---------------------------------------------------
use strict;
use CGI ();
use CGI::Carp qw/fatalsToBrowser/;
use lib 'ev-admin121';
use Links;
use Links::DB_Utils;
use Links::HTML_Templates;
use Links::DBSQL;
$|++;

&main();

sub main {
# ---------------------------------------------------
# Determine what to do.
#
my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;

if ($in->param('giveme')) {
&get_password ($in, $dynamic);
}
else {
print $in->header();
&site_html_forgot_form ( {}, $dynamic);
}
}
# ==============================================================

sub get_password {
# --------------------------------------------------------
#
my ($in, $dynamic) = @_;
my $user = $in->param('Username');
my $in_r = &cgi_to_hash ($in);

# Verify username field
if (! $user) {
print $in->header();
&site_html_forgot_form ( { error => "Please enter a username", %{$in_r} }, $dynamic );
return;
}

# Check that the username exist.
my $db = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Users.def";
my $user_r = $db->get_record ($user, 'HASH');
if (! $user_r) {
print $in->header();
&site_html_forgot_form ( { error => "Sorry that username does not exist", %{$in_r} }, $dynamic );
return;
} else {

# Prepare the message.
my $msg = &load_template ('email-pass.txt', { %LINKS, %$in_r });

# Mail the password request letter.
require Links::Mailer;
my $mailer = new Links::Mailer ( { smtp => $LINKS{db_smtp_server},
sendmail => $LINKS{db_mail_path},
from => $LINKS{db_admin_email},
subject => "Password Request",
to => $in->param('Email'),
msg => $msg
} ) or die $Links::Mailer::error;
$mailer->send or die $Links::Mailer::error;
&site_html_add_form ( {}, $dynamic)
}
}
## End here

Users.def :

Û_def = (
Username => ['1', 'CHAR', '25', '25', '1', '', ''],
Password => ['2', 'CHAR', '25', '25', '1', '', ''],
Email => ['3', 'CHAR', '40', '50', '0', '', ''],
Validation => ['4', 'CHAR', '20', '20', '0', '', ''],
Status => ['5', 'CHAR', '0', '13', '1', 'Not Validated', 'Not Validated|Registered|Editor|Administrator'],
Company_Name => ['6', 'CHAR', '40', '50', '1', '', ''],
Address => ['7', 'CHAR', '40', '50', '1', '', ''],
City => ['8', 'CHAR', '40', '50', '1', '', ''],
State => ['9', 'CHAR', '40', '50', '1', '', ''],
Zip => ['10', 'CHAR', '15', '15', '1', '', ''],
Country => ['11', 'CHAR', '30', '30', '1', '', ''],
Phone => ['12', 'CHAR', '20', '20', '1', '', '']
);

Please help, I can't get it to work. It always brought me to the forgot form page. But sometimes I got this message :

"No message body specified"


Thanks

Quote Reply
Re: Password Reminder In reply to
Sorry, have no time at the moment to solve your problem and im no programmer! If you want to do the mod with another field in another database table you should do it with changing the tragets of the script. Read it and try out. Sorry.