Hi there. About a month ago, I made this mod to my site. I decided to wait to release it just to make sure it was compatible with Links SQL 1.1. Here is some instructions:
First of all, you need to have a field in your database with the name Password, that contains the password for the link.
Then, in your modify.cgi you should change your sub main with this one:
# ---------------------------------------------------
# Determine what to do.
#
my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;
%in = %{&cgi_to_hash($in)};
print $in->header('text/html');
if ($in->param('modify')) {
&process_form ($in, $dynamic);
}
else {
if ($in->param('SiteID') =~ /^\d+$/) {
my $db = new Links:
BSQL $LINKS{admin_root_path} . "/defs/Links.def";
my $rec = $db->get_record ($in->param('SiteID'), 'HASH');
$rec or &site_html_modify_first ( { erro => "ID Unknow", SiteID => $in->param('SiteID'), Password => $in->param('Password') } ) and return;
if ($rec->{'ID'} eq $in->param('SiteID')) {
if ($rec->{'Password'} eq $in->param('Password')) {
my ($name, $category);
my $id = $rec->{'CategoryID'};
# If we don't have an id, and can't generate a list, let's send the user a message.
if (! $id and ! $LINKS{db_gen_category_list}) {
&site_html_error ( { error => "Please first go to the category that you want the listing to be in and click from there." }, $dynamic);
}
else {
if ($id) {
$name = &get_category_name ($id);
$name ?
($category = "$name <input type=hidden name='CategoryID' value='$id'>") :
($category = &get_category_list ());
$category = &get_category_list ($id);
}
else { $category = &get_category_list (); }
&site_html_modify_form ( { %$rec, Category => $category, %in }, $dynamic);
}
&site_html_modify_form ( $rec, { Category => $category } ) and return;
}
else {
&site_html_modify_first ( { erro => "Wrong password", SiteID => $in->param('SiteID'), Password => $in->param('Password') } );
}
}
else {
&site_html_modify_first ( { erro => "ID Unknow", SiteID => $in->param('SiteID'), Password => $in->param('Password') } );
}
}
else {
&site_html_modify_first ( { SiteID => '', Password => ''} );
}
}
}
# ==============================================================
The next step, is to modify your templates.
You need and template called modify_first.html. You can use this code:
<html>
<head>
<title><%site_title%>: Modify a Resource</title>
<link rel=stylesheet href="<%css%>" type="text/css" title="style sheet">
</head>
<body>
<h1><%site_title%>: Modify a Resource</h1>
<%include header.txt%>
<form action="<%db_cgi_url%>/modify.cgi" method="POST">
<p>Before anything, you should provide us your ID and Password:</p>
<%if erro%>
<p>There was an error: <font color="red"><%erro%></font></p>
<%endif%>
<div class="margin">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td align="right" valign="top">ID:</td>
<td><input name="SiteID" value="<%SiteID%>" size="50"></td></tr>
<tr><td align="right" valign="top">Password:</td>
<td><input name="Password" value="<%Password%>" size="50"></td></tr>
<tr><td></td><td><input type="SUBMIT" name="modify" value="Modify Resource"></td></tr>
</table>
</div>
</form>
<%include footer.txt%>
</body>
</html>
Well, then you need to edit modify.html template, to show the site info. To do this, open your file, and where you find the form html code, you should modify where is value="" to value="<%Field%>" changing Field to the field it correspond.
Well, I know this is an ugly explanation, but if something dont work, or you dont get it, please tell me.
Also, you may add, if you want, the codes to show the user his/her password, in the email, and the other things. Also you should add and option to the user in the add*.html templates. So he/she can guive a password to the system.
Again, if you dont understand something, ask me, than I will guive more details.
See ya!
[This message has been edited by tmoretti (edited December 23, 1999).]
First of all, you need to have a field in your database with the name Password, that contains the password for the link.
Then, in your modify.cgi you should change your sub main with this one:
Code:
sub main { # ---------------------------------------------------
# Determine what to do.
#
my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;
%in = %{&cgi_to_hash($in)};
print $in->header('text/html');
if ($in->param('modify')) {
&process_form ($in, $dynamic);
}
else {
if ($in->param('SiteID') =~ /^\d+$/) {
my $db = new Links:

my $rec = $db->get_record ($in->param('SiteID'), 'HASH');
$rec or &site_html_modify_first ( { erro => "ID Unknow", SiteID => $in->param('SiteID'), Password => $in->param('Password') } ) and return;
if ($rec->{'ID'} eq $in->param('SiteID')) {
if ($rec->{'Password'} eq $in->param('Password')) {
my ($name, $category);
my $id = $rec->{'CategoryID'};
# If we don't have an id, and can't generate a list, let's send the user a message.
if (! $id and ! $LINKS{db_gen_category_list}) {
&site_html_error ( { error => "Please first go to the category that you want the listing to be in and click from there." }, $dynamic);
}
else {
if ($id) {
$name = &get_category_name ($id);
$name ?
($category = "$name <input type=hidden name='CategoryID' value='$id'>") :
($category = &get_category_list ());
$category = &get_category_list ($id);
}
else { $category = &get_category_list (); }
&site_html_modify_form ( { %$rec, Category => $category, %in }, $dynamic);
}
&site_html_modify_form ( $rec, { Category => $category } ) and return;
}
else {
&site_html_modify_first ( { erro => "Wrong password", SiteID => $in->param('SiteID'), Password => $in->param('Password') } );
}
}
else {
&site_html_modify_first ( { erro => "ID Unknow", SiteID => $in->param('SiteID'), Password => $in->param('Password') } );
}
}
else {
&site_html_modify_first ( { SiteID => '', Password => ''} );
}
}
}
# ==============================================================
The next step, is to modify your templates.
You need and template called modify_first.html. You can use this code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html>
<head>
<title><%site_title%>: Modify a Resource</title>
<link rel=stylesheet href="<%css%>" type="text/css" title="style sheet">
</head>
<body>
<h1><%site_title%>: Modify a Resource</h1>
<%include header.txt%>
<form action="<%db_cgi_url%>/modify.cgi" method="POST">
<p>Before anything, you should provide us your ID and Password:</p>
<%if erro%>
<p>There was an error: <font color="red"><%erro%></font></p>
<%endif%>
<div class="margin">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td align="right" valign="top">ID:</td>
<td><input name="SiteID" value="<%SiteID%>" size="50"></td></tr>
<tr><td align="right" valign="top">Password:</td>
<td><input name="Password" value="<%Password%>" size="50"></td></tr>
<tr><td></td><td><input type="SUBMIT" name="modify" value="Modify Resource"></td></tr>
</table>
</div>
</form>
<%include footer.txt%>
</body>
</html>
Well, then you need to edit modify.html template, to show the site info. To do this, open your file, and where you find the form html code, you should modify where is value="" to value="<%Field%>" changing Field to the field it correspond.
Well, I know this is an ugly explanation, but if something dont work, or you dont get it, please tell me.
Also, you may add, if you want, the codes to show the user his/her password, in the email, and the other things. Also you should add and option to the user in the add*.html templates. So he/she can guive a password to the system.
Again, if you dont understand something, ask me, than I will guive more details.
See ya!
[This message has been edited by tmoretti (edited December 23, 1999).]