Gossamer Forum
Home : Products : Links 2.0 : Customization :

Modify Password

(Page 1 of 2)
> >
Quote Reply
Modify Password
This cry for help is in relation to password modify for Templates @ http://www.asan.com/users/phoenix/modify/

I have installed the script as stated at the page but nothing ever works. I have tried many differnet ways.

This is the modify page i have:

<FORM ACTION="<Û_cgi_url%>/modify.cgi" METHOD="POST">
<P>Title:
<BR><INPUT NAME="Title" VALUE="<%Title%>" SIZE="47">
<BR>URL:
<BR><INPUT NAME="URL" VALUE="<%URL%>" SIZE="47">
<BR>Category:
<BR>
<Êtegory%>
<BR>Description:
<BR><TEXTAREA WRAP="virtual" NAME="Description" ROWS="3" COLS="42"><Þscription%></TEXTAREA>
<BR>Contact Name:
<BR><INPUT NAME="Contact Name" VALUE="<%Contact Name%>" SIZE="47">
<BR>Contact Email
<BR><INPUT NAME="Contact Email" VALUE="<%Contact Email%>" SIZE="47">
<BR>password:
<BR><INPUT NAME="password" VALUE="<%password%>" SIZE="47">
<BR><INPUT TYPE="Hidden" NAME="ID" VALUE="<%ID%>">
<B><input type="SUBMIT" Name="Submit" value="modify Resource"></B>
</P>
</FORM>

This is my modify.cgi script

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

# We are processing the form.
if ($in{'Submit'}) {
&process_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 ("Unkown Link ID: $in{'ID'}");
}
}
else {
&site_html_modify_first;
}
}
}


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

# Make sure we have a link to modify.
#!$in{'Current URL'} and &site_html_modify_failure ("did not specify link to modify") and return;

# 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 ­d_system_fields) {
$in{$key} = $original{$key};
}

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

# 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;

# Print out the modified record to a "modified database" where it is stored until
# the admin decides to add it into the real database.
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;
}
else {
# Let's change that error message from a comma delimted list to an html
# bulleted list.
&site_html_modify_failure($status);
}
}

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'}
Description: $original{'Description'}
Country: $original{'Country'}
Type: $original{'Type'}
Contact Name: $original{'Contact Name'}
Contact Email: $original{'Contact Email'}
Category: $original{'Category'}

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

Remote Host: $ENV{'REMOTE_HOST'}
Referer: $ENV{'HTTP_REFERER'}

To update, please go to:
$db_script_url

Sincerely,

Links Manager.
|;

# 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;
}



This is the updated site_html_template.cgi

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_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
});
}


And i have added the password var to the links.def file.
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
password => [14, 'alpha', 10, 10, 1, '', '']
);

# Database file to use -- defined in links.cfg.
$db_file_name = $db_links_name;
# Counter file to use -- defined in links.cfg.
$db_id_file_name = $db_links_id_file_name;
# The column name for the database key.
$db_key = 'ID';
# Database delimeter.
$db_delim = '|';
# Title used in admin output.
$html_title = 'Links Database';
$html_object = 'Link';

# Field Number of some important fields. The number is from Û_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_password = 14;


But i still get directed to the error page when i try to modify a site. Can anyone help.


Quote Reply
Re: Modify Password In reply to
WHY did you post a duplicate Thread??? Didn't any of the answers Bobsie and I provide help you? If not, you should've kept posting replies in the SAME THREAD!

Anyway...After adding the password field to your links.def DID you update your links.db by adding this new field in all your records??????

Because if you didn't then your links.db is corrupt and, of course, the new modify.cgi script will NOT work.

Got it?


Eliot Lee
Quote Reply
Re: Modify Password In reply to
The only reply i got was from catflay who said the script had lots of bugs anyway and he was posting a new script to the resources section.

Quote Reply
Re: Modify Password In reply to
Well, did you read my reply...DID you update your links.db or NOT?

Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
By this you mean clearing the database. Yes i have done that. It still doesn't work.

Quote Reply
Re: Modify Password In reply to
No...I don't mean clearing the database...I mean updating your existing database with the new field.

Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
How would i do that. oUT OF INTEREST i guess you must have got the modify password script located at http://www.asan.com/users/phoenix/modify/ working. Why is it i was informed that this code is full of bugs and doesn't work.

Quote Reply
Re: Modify Password In reply to
It is buggy for people who don't understand the following concepts:

1) Adding fields to the links.def file.
2) Updating current databases.
3) Using proper case settings of hash values, field values, and variable values.

For updating your database...there is a script located in the Add Fields FAQ in the Resource Center.

Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
Thank you for your help i have updated the DB but it still doesn't work, When i try to modify a link i get an error page when i clickon submit.

Quote Reply
Re: Modify Password In reply to
You must EDIT YOUR links.def script BEFORE entering these variable and running this script!
$field_default = "password"; #Put the default value of the new field here. Leave Blank for no default.
$new_field = "15"; #Put the new field number here.
$total_fields = "15"; #Put the last field number here.
#Change these value to match your settings
require "../db_utils.pl";
require "../links.def";

This is what i put.....i ran the script but the modify password still doesn' work.

Quote Reply
Re: Modify Password In reply to
So, you are using password as the default value for all your password fields in the links.db file, right?

And you are using password in the password field in the modify form?

Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
I would also recommend changing the following codes in the sub main routine in the modify.cgi file:

Code:

if ($rec{'password'} eq $in{'password'}) {


to the following:

Code:

if ( ($rec{'ID'} eq $in{'ID'}) and
($rec{'password'} eq $in{'password'}) and
($rec{'Contact Name'} eq $in{'Contact Name'})) {


Then change the following codes:

Code:

else {
&site_html_modify_failure ("password Invalid: $in{'password'}");
}


with the following codes:

Code:

else {
&site_html_modify_failure ("Invalid Login Information: $in{'password'}, $in{'Contact Name'}, $in{'ID'}");
}


AND you also have to create a template file called modify_first.html and in that template file, include ONLY the following form codes:

Code:

<form action="post" action="<%db_cgi_url%>/modify.cgi">
ID: <input type="text" name="ID" value="<%ID%>">
Username: <input type="text" name="Contact Name" value="<%Contact Name%>">
Password: <input type="text" name="password" value="<%password%>">
</form>


Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
Thats correct my DB looks like this

1|Gamesnstuff|http://www.gamesnstuff.com|1-Jul-2000|PC/General|Gaming site.|Andrew Fuller||andrew@gamesnstuff.com|Yes|No|No|4.00|1|Yes|password
2|sdfsf|http://www.dsfsdsds.com|1-Jul-2000|Dreamcast/Adventure|asdas|Andrew|andrew@gamesnstuff.com|0|Yes|No|0|0|Yes||password
3|ARE YOU A GAMER? IF THE ANSWER IS YES, VISIT GAMESNLINK|http://www.dsfsdsds.com|1-Jul-2000|Dreamcast|sdfsdf|Andrew Fuller|andrew@gamesnstuff.com|0|Yes|No|0|0|Yes||poo

But i still get an error page when i try to modify a link.

Quote Reply
Re: Modify Password In reply to
Did you read my latest reply or did you choose to ignore it? Mad

Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
I have adjusted the code and now when i go to modify a resource i get a 'unkown tag:ID' error.

Quote Reply
Re: Modify Password In reply to
Even better now i get an internal server error

Quote Reply
Re: Modify Password In reply to
this is what my sub_main looks like:

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

# We are processing the form.
if ($in{'Submit'}) {
&process_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{'ID'} eq $in{'ID'}) and($rec{'password'} eq $in{'password'}) and($rec{'Contact Name'} eq $in{'Contact Name'})) {
&site_html_modify_form (%rec);
}
else {&site_html_modify_failure ("Invalid Login Information: $in{'password'}, $in{'Contact Name'}, $in{'ID'}");}

}
}
else {
&site_html_modify_failure ("Unkown Link ID: $in{'ID'}");
}
}
else {
&site_html_modify_first;
}
}
}


sub process_form {

Quote Reply
Re: Modify Password In reply to
See the space in the following codes:

Code:

if ( ($rec{'ID'} eq $in{'ID'})


REMOVE IT!

Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
You have to add hidden fields in your modify.html file, like the followng:

Code:

<input type="hidden" name="ID" value="<%ID%>">


Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
What do yo mean.......

Like this

if (($rec{'ID'} eq $in{'ID'}) and($rec{'password'}

Quote Reply
Re: Modify Password In reply to
If that is what you mean i tried it and it still doesn't work.

Quote Reply
Re: Modify Password In reply to
Welp...I don't know what to tell you...Did you make the recommended changes to your modify_first.html file???

Do you even have a modify_first.html file? All I can recommend at this point is that you make text copies (.txt) of the following files:

1) modify.cgi
2) modify_first.html
3) modify.html
4) modify_error.html
5) modify_success.html
6) ALL the modify sub-routines in your site_html_templates.pl file

Then upload these text files to a publicly accessible directory in your WEB SERVER. Then post the URLs to these files...so, that we can help you debug each of the files, because the codes I provided you DO WORK in my site, and it seems that either you have confused the codes I've posted OR not followed ALL the instructions in the Mod page.

Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
I have uploaded the files:

to

1) http://www.gamebo.com/links/modify_cgi.txt
2) http://www.gamebo.com/links/modify_first.txt
3) http://www.gamebo.com/links/modify_htmltxt
4) http://www.gamebo.com/links/modify_error.txt
5) http://www.gamebo.com/links/modify_success.txt
6) http://www.gamebo.com/links/site_html_templates.txt
7) http://www.gamebo.com/links/links_def.txt



Quote Reply
Re: Modify Password In reply to
Here are the problems with your files:

site_html_templates.pl

sub site_html_modify_first

You are missing the %in hash, which is probably the source of the login problem since data cannot be parsed properly. The sub should look like the following:

Code:

sub site_html_modify_first {
#---------------------------------------------------------
# Modify Access Form

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


modify_first.html

You need to add a submit button to your modify.cgi form codes, like the following:

Code:

<INPUT TYPE="submit" VALUE="Send">


before the </form>.

Hope this works and helps.

Regards,

Eliot Lee
Quote Reply
Re: Modify Password In reply to
I am still getting an internal error on my modify.cgi.

> >