Gossamer Forum
Home : Products : Links 2.0 : Customization :

simple password protect modify.cgi mod

Quote Reply
simple password protect modify.cgi mod
I dunno if i am not thinking this through enough or what but all the password protect modify link mods i found were unbeleavably complicated and none seemed to work real well so i made one myself. It is not secure by any means ... kinda like a locking doorknob, its just there to keep honest folk out but i dont think with the modifications being added to the review que it needs to be that secure so for anyone who wants it - here it is:

open modify.cgi
find
Code:
$found = 0;
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
if ($data[$db_url] eq $in{'Current URL'}) {
$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;



and replace with
Code:
$found = 0;
$nopass = 0;
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);
if ($data[$db_url] eq $in{'Current URL'}) {
$found = 1;
if ($data[$db_pass] eq $in{'Password'}) {
$in{$db_key} = $data[0];
$nopass = 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;
!$nopass and &site_html_modify_failure ("password was not correct") and return;


then in links.def replace
Code:
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$']


with
Code:
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
pass => [13, 'alpha', 10, 10, 1, '', '']


then find
Code:
# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.


and add this at the end of the list
Code:

$db_pass = 13;



dont forget to add a "Password" field right below the "Current URL" field on your modify.html template or sub site_html_modify_form code if you dont use templates as well as a "pass" field to the add a link form

i havent played with it much but ill bet you can even put a link to your email addy if they loose their password. you would have to look it up but its much easier than writing a script if your list is low volume

hope that helps :)




Vote Stinky

Last edited by:

security_man: Dec 19, 2005, 10:41 PM