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.
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.