Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Password mod's not working

Quote Reply
Password mod's not working
Hi everybody, My name is Gil. I am new to this forum. I design and build websites, mostly for Dutch company's. /bin doing that for 2 years. I am using links 2.0 for a new (personal) website. it's al working great but still testing and trying out.

One question about a links 2.0 password mod that I found on http://www.asan.com/users/phoenix/modify/. I keep getting the same error message after uploading the modified files:

error message: /cgi-bin/links/admin/links.def line 37, near "Password"

That's where I added Password => [20, 'alpha', 10, 10, 1, '', '']and a few lines down add $db_password = 20;

I changed 20 into 14.

When I put back the links.def original file, and keep the modified files (the ones that needed modifications to make the mod work) the error message is gone and everything is working again. (though the passwd feature is not added)

Besides the error message, my browser keeps offering me to download the script when I try to build, or view or add anything. Often this is caused by wrong permissions.

I'd be very happy if someone can help me out. I do not mind if someone needs to enter my server to check things out. I did read lot's of messages, and and searched for an answer in the resource center, without any succes..

Thanks a lot!

Gil

Quote Reply
Re: Password mod's not working In reply to
The error means that you did not add a comma after the previous line in the %db_def hash before the line where the Password field is defined.

In Reply To:
Besides the error message, my browser keeps offering me to download the script when I try to build, or view or add anything. Often this is caused by wrong permissions.
Welp...download it and open it in a text editor...you will see an error message.

Wink

Regards,

Eliot Lee

Quote Reply
Re: Password mod's not working In reply to
Hi, GreaT.

You were right! What a relief!

Thanks a lot!
Gil


Quote Reply
Re: Password mod's not working In reply to
You're welcome.

Regards,

Eliot Lee

Quote Reply
Re: Password mod's not working In reply to
Hi,

I've tried to make it work completely, and, a few hours later I am quite close. Passwords are logged, and mailed by request. Modifying a link and logging in with the new form (ID and passwd) gives the following error: Unkown Tag: ID

When I go back and enter the wrong pass and submit I get a different error: Unkown Tag: Current URL

Any suggestions on how to fix this?

Thanks a lot!
Gil


Quote Reply
Re: Password mod's not working In reply to
You have not edited the modify_first.html template file correctly. And you probably did not completely edit the modify.cgi file...you should NOT have CurrentURL in the modify.cgi file.

Regards,

Eliot Lee

Quote Reply
Re: Password mod's not working In reply to
Hi!

http://www.asan.com/users/phoenix/modify/

I've really tried to exactly follow the above instructions but still the same error. I edited links.def, modify.cgi and site_html_templates.pl. Also added the new templates.
????

http://www.sitedynamics.nl/cgi-bin/links/modify.cgi is where it's happening (actually not happening) one ID and pass combination that is correct is ID: 4 pass: potlood

I checked the database and it's all there in the right place

Thanks so far,

Gil


Quote Reply
Re: Password mod's not working In reply to
Here's a solution for Password Mod and Modify Confirm.

In modify.cgi overwrite the subs below with yours, but don't erase the copyright info and required libraries.
In send_email erase what you don't need to be sent or what you're currently not using. eg: Keywords: $original{'Keywords'}

sub main {
# --------------------------------------------------------
local (%in) = &parse_form;

# We are processing the form.
if ($in{'submit_form'}) {
&process_form;
}
elsif ($in{'send_form'}) {
&send_form;
}

# Otherwise we are displaying the form (in site_html.pl), displaying
# the entrance (Asks for Link ID and Password)
else {
if ($in{'ID'} =~ /^\d+$/) {
my (%rec) = &get_record ($in{'ID'});

if ($rec{$db_key} eq $in{'ID'}) {
if ($rec{'Password'} eq $in{'password'}) {
&site_html_modify_form (%rec);
}
else {
&site_html_modify_failure ("Password Invalid: $in{'password'}");
}
}
else {
&site_html_modify_failure ("Unknown Link ID: $in{'ID'}");
}
}
else {
&site_html_modify_first;
}
}
}

sub process_form {
# --------------------------------------------------------
my ($key, $status, @values, $found);
local (%original);

# Let's check to make sure the link we want to update is actually in the database.
open (DB, "<$db_file_name") or &cgierr("error in validate_records. unable to open db file: $db_file_name. Reason: $!");
$found = 0;
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
if ($data[$db_key] eq $in{'ID'}) {
$in{$db_key} = $data[0];
$found = 1;
%original = &array_to_hash (0, @data);
last LINE;
}
}
close DB;
!$found and &site_html_modify_failure ("link was not found in the database") and return;

# Since we have a valid link, let's make sure the system fields are set to their
# proper values. We will simply copy over the original field values. This is to stop
# people from trying to modify system fields like number of hits, etc.
foreach $key (keys %add_system_fields) {
$in{$key} = $original{$key};
}

# Set date variable to today's date.
$in{$db_cols[$db_modified]} = &get_date;

# Set date variable to the dateadded.
$in{$db_cols[$db_dateadded]} = $original{'DateAdded'};

# Validate the form input..
$status = &validate_record(%in);
if ($status eq "ok") {

# First make sure the link isn't already in there.
open (MOD, "<$db_modified_name") or &cgierr ("error opening modified database: $db_modified_name. Reason: $!");
while (<MOD>) {
chomp;
@values = split /\|/;
if ($values[0] eq $in{$db_key}) {
close MOD;
&site_html_modify_failure("A request to modify this record has already been received. Please try again later.");
return;
}
}
close MOD;

# Send the visitor to the Confirmation page.
&site_html_modify_confirm;
}
else {
# Let's change that error message from a comma delimted list to an html
# bulleted list.
&site_html_modify_failure($status);
}
}

sub send_form {
# --------------------------------------------------------
my ($key, $status, $line, $output);
local (%original);

# Let's check to make sure the link we want to update is actually in the database.
open (DB, "<$db_file_name") or &cgierr("error in validate_records. unable to open db file: $db_file_name. Reason: $!");
$found = 0;
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
if ($data[$db_key] eq $in{'ID'}) {
$in{$db_key} = $data[0];
$found = 1;
%original = &array_to_hash (0, @data);
last LINE;
}
}
close DB;
!$found and &site_html_modify_failure ("link was not found in the database") and return;

# Set date variable to today's date.
$in{$db_cols[$db_modified]} = &get_date;

# Set date variable to the dateadded.
$in{$db_cols[$db_dateadded]} = $original{'DateAdded'};

# Print out the modified record to a "modified database" where it is stored until
# the admin decides to add it into the real database. Ensure we retain the original
# date the record was added.
$in{$db_cols[$db_dateadded]} = $original{'DateAdded'};
open (MOD, ">>$db_modified_name") or &cgierr("error in modify.cgi. unable to open modification database: $db_modified_name. Reason: $!");
flock(MOD, $LOCK_EX) unless (!$db_use_flock);
print MOD &join_encode(%in);
close MOD; # automatically removes file lock

# Send the admin an email message notifying of new addition.
&send_email;
# Send the visitor to the success page.
&site_html_modify_success;
}

sub send_email {
# --------------------------------------------------------
# Sends an email to the admin, letting him know that there is
# a new link waiting to be validated.

# 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 = "Modification to Database: $in{'Title'}";
my $msg = qq|
The following link was modified and is awaiting validation:

ORIGINAL LINK:
===============================================
Title: $original{'Title'}
URL: $original{'URL'}
Category: $original{'Category'}
Description: $original{'Description'}
Keywords: $original{'Keywords'}
Contact Name: $original{'Contact Name'}
Contact Email: $original{'Contact Email'}
Password: $original{'Password'}

Remote Domain: $original{'Domain'}
Remote Host: $original{'Host'}
Remote IP Address: $original{'IP'}
Referer: $ENV{'HTTP_REFERER'}


NEW LINK:
===============================================
Title: $in{'Title'}
URL: $in{'URL'}
Category: $in{'Category'}
Description: $in{'Description'}
Keywords: $in{'Keywords'}
Contact Name: $in{'Contact Name'}
Contact Email: $in{'Contact Email'}
Password: $in{'Password'}

Remote Domain: $in{'Domain'}
Remote Host: $in{'Host'}
Remote IP Address: $ENV{'REMOTE_ADDR'}
Referer: $ENV{'HTTP_REFERER'}

To update, please go to:
$db_script_url


Sincerely,

Macau Search Engine
|;

# 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 undef;
$mailer->send or return undef;
}

Change your html files as follow:
In modify.html:
<input type="SUBMIT" name="submit_form" value="Modify Resource">

In modify_confirm.html:
<input type="SUBMIT" name="send_form" value="Submit">

In modify_first.html:
<INPUT TYPE="submit" NAME="Submit" VALUE="Send">

Thats all, if you can't get this work you can send me all the files required by modify.cgi eg: modify_***.html, modify.cgi & site_html_template.pl and I do it for you, but if you need my help maybe you need to wait some hours. Try by yourself first.

Regards,




Nuno Duque
--------------------
Macau Search Engine
searchmacau.com
Quote Reply
Re: Password mod's not working In reply to
Hi, Thanks alot. I didn't get it to work.

I followed your instructions. I changed modify.pl. You were using a sub (sub send_form) that wasn't in my original modify.pl, so I added this. Password request is working except login in with ID and passwd isn't working: Unkown Tag: ID is the error message that is returned. I'd be happy to send you the required files

modify.pl
site_html_templates.pl
+3 templates.

How can I send them to you?

Thanks a lot!
Gil


Quote Reply
Re: Password mod's not working In reply to
Send your files including links.def and links.cfg to gilhelp@searchmacau.com, but give some time to do it because I'm very busy.



I'm waiting,

Nuno Duque
--------------------
Macau Search Engine
searchmacau.com
Quote Reply
Re: Password mod's not working In reply to
I'm very busy installing for about 45 mods into my links and I already installed 28 mods, but I decided to help you today so you don't need to waste more time waiting for the bug fix.
I already logged into your server and changed all scripts to support the password mod and modify confirm mod, now you can delete the temporary password in your server because I finish my job.
Now you get a new page when modifying links, this is usefull, because the user can change the errors before sending to the server, hope you like it, but if you don't like this mod, simply change the code in modify.html from <input type="SUBMIT" name="submit_form" value="Modify Resource"> to <input type="SUBMIT" name="process_form" value="Modify Resource">, so easy yeah?
You can see what was the problem before because I just overwrited two files but the other I added a "1" at the finish of each file name.
I change some bugs in 6 files and I make one template file for you "modify_confirm.html", as follow:
modify.cgi
site_html_templates.pl
modify_first.html
modify.html
modify_confirm.html
modify_success.html
modify_error.html


Regards,

Nuno Duque
--------------------
Macau Search Engine
searchmacau.com
Quote Reply
Re: Password mod's not working In reply to
Okay I got past the modify_first and onto the modify.html...when I submit the changes it goes back to modify_first.html. What could I be doing wrong? I used your script. Here is my site_html_templates.pl section:
Code:
sub site_html_modify_first {
#---------------------------------------------------------
# displays the form for users to enter the ID number and
# Password for the Link they wish to modify

&html_print_headers;
print &load_template ('modify_first.html', {
%globals
});
}


sub site_html_modify_form {
# --------------------------------------------------------
# This routine determines how the modify form page will look like.

my %rec = @_;
my $category = &build_select_field ("Category", "$rec{'Category'}");

&html_print_headers;
print &load_template ('modify.html', {
category => $category,
%rec,
%globals
});
}


sub site_html_modify_success {
# --------------------------------------------------------
# This routine determines how the modify success page will look like.

&html_print_headers;
print &load_template ('modify_success.html', {
%in,
%globals
});
}

sub site_html_modify_failure {
# --------------------------------------------------------
# This routine determines how the modify failure page will look like.

my $errormsg = shift;
$in{'Category'} = &build_select_field ("Category", $in{'Category'});

&html_print_headers;
print &load_template ('modify_error.html', {
error => $errormsg,
%in,
%globals
});
}
Quote Reply
Re: Password mod's not working In reply to
Currently I'm very busy, if this thread can't help you, please see my post using Search function above.
Your problem seems to be in the modify.cgi, I have enclosed my modifications below for your appreciation:


In site_html_templates.pl check this

sub site_html_modify_first {
#---------------------------------------------------------
# displays the form for users to enter the ID number and
# Password for the Link they wish to modify

# USED BY: gethostbyaddr
use Socket;

&html_print_headers;

my $mipaddress = $ENV{'HTTP_X_FORWARDED_FOR'};
my $mhostname = scalar(gethostbyaddr(inet_aton($mipaddress), AF_INET));
my $mhostdomain = $1 if $mhostname =~ /.*\.([^.]*\.[^.]*)/;
my $mserverip = $ENV{'REMOTE_ADDR'};

print &load_template ('modify_first.html', {
MIP => $mipaddress,
MDomain => $mhostdomain,
MHost => $mhostname,
MServerIP=> $mserverip,
%globals
});
}

sub site_html_modify_form {
# --------------------------------------------------------
# This routine determines how the modify form page will look like.

# USED BY: gethostbyaddr
use Socket;

my %rec = @_;
my $mipaddress = $ENV{'HTTP_X_FORWARDED_FOR'};
my $mhostname = scalar(gethostbyaddr(inet_aton($mipaddress), AF_INET));
my $mhostdomain = $1 if $mhostname =~ /.*\.([^.]*\.[^.]*)/;
my $mserverip = $ENV{'REMOTE_ADDR'};
my $category = &build_select_field ("Category", "$rec{'Category'}");

&html_print_headers;
print &load_template ('modify.html', {
MIP => $mipaddress,
MDomain => $mhostdomain,
MHost => $mhostname,
MServerIP=> $mserverip,
category => $category,
%rec,
%globals
});
}

sub site_html_modify_confirm {
# --------------------------------------------------------
# This routine determines how the confirm success page will look like.

# USED BY: gethostbyaddr
use Socket;

my %rec = @_;
my $mipaddress = $ENV{'HTTP_X_FORWARDED_FOR'};
my $mhostname = scalar(gethostbyaddr(inet_aton($mipaddress), AF_INET));
my $mhostdomain = $1 if $mhostname =~ /.*\.([^.]*\.[^.]*)/;
my $mserverip = $ENV{'REMOTE_ADDR'};
my $category = shift;
my $clean_category = &build_clean($category);
$category ?
($category = qq~$clean_category <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));

&html_print_headers;
print &load_template ('modify_confirm.html', {
MIP => $mipaddress,
MDomain => $mhostdomain,
MHost => $mhostname,
MServerIP=> $mserverip,
category => $category,
%in,
%globals
});
}



sub site_html_modify_success {
# --------------------------------------------------------
# This routine determines how the modify success page will look like.

# USED BY: gethostbyaddr
use Socket;
my $mipaddress = $ENV{'HTTP_X_FORWARDED_FOR'};
my $mhostname = scalar(gethostbyaddr(inet_aton($mipaddress), AF_INET));
my $mhostdomain = $1 if $mhostname =~ /.*\.([^.]*\.[^.]*)/;
my $mserverip = $ENV{'REMOTE_ADDR'};

&html_print_headers;
print &load_template ('modify_success.html', {
MIP => $mipaddress,
MDomain => $mhostdomain,
MHost => $mhostname,
MServerIP=> $mserverip,
%in,
%globals
});
}

sub site_html_modify_failure {
# --------------------------------------------------------
# This routine determines how the modify failure page will look like.

# USED BY: gethostbyaddr
use Socket;

my $errormsg = shift;
my $mipaddress = $ENV{'HTTP_X_FORWARDED_FOR'};
my $mhostname = scalar(gethostbyaddr(inet_aton($mipaddress), AF_INET));
my $mhostdomain = $1 if $mhostname =~ /.*\.([^.]*\.[^.]*)/;
my $mserverip = $ENV{'REMOTE_ADDR'};
if ($in{'Category'}) {
($in{'Category'} =
qq~$in{'Category'}<input type=hidden name="Category" value="$in{'Category'}">~);
}
else {
if (!@exclude_categories) {
($in{'Category'} = &build_select_field ("Category"));
}
else {
($in{'Category'} = &get_cat_select_list);
}
}

&html_print_headers;
print &load_template ('modify_error.html', {
error => $errormsg,
MIP => $mipaddress,
MDomain => $mhostdomain,
MHost => $mhostname,
MServerIP=> $mserverip,
%in,
%globals
});
}


In modify.cgi check this

# We are processing the form.
if ($in{'submit_form'}) {
&process_form;
}
elsif ($in{'send_form'}) {
&send_form;
}

# Otherwise we are displaying the form (in site_html.pl), displaying
# the entrance (Asks for Link ID and Password)
else {
if ($in{'ID'} =~ /^\d+$/) {
my (%rec) = &get_record ($in{'ID'});

if ($rec{$db_key} eq $in{'ID'}) {
if ($rec{'Password'} eq $in{'password'}) {
&site_html_modify_form (%rec);
}
else {
&site_html_modify_failure ("Password Invalid: $in{'password'}");
}
}
else {
&site_html_modify_failure ("Unknown Link ID: $in{'ID'}");
}
}
else {
&site_html_modify_first;
}
}
}


Regards,

Nuno Duque
--------------------
Macau Search Engine
inmacau.com