Ive been workin on a webgame where i would like anybody to be able to go to my site register an account, and start using it immidiately.
i dont know how to set it up so that other people can make thier own passwords, and store it on the servery my site is on without me having to give them a password every time.
if anyone can help me out with some info on how to get it set up to run automatically, i would appreciate it.
BTW: the site has tons of useful info for any net junkey. thanks for the help i have already recieved.
You probably should choose delimiters other than : and \n that won't appear in the user's typed input.
Craiga open(DAT,"file.txt");
while(<DAT>){
($username,$password) = split(/:/);
}
close DAT;
You should always check the return value of open. You also need to lock the file, otherwise it becomes more and more likely your data will become corrupted the more often it is called. You will also have a newline appended to every password.
Craiga open(DAT,">>file.txt");
print DAT "$username:$password\n";
close DAT;
Again, _must_ lock the file.
$^W = 1;
use strict;
use CGI;
use Fcntl qw{:flock :seek};
sub UNIT_SEPARATOR() { "\x1f" }
sub RECORD_SEPARATOR() { "\x1e" }
my %user;
# read from flat file db
open DAT, '+>>file.txt' or die $!;
seek DAT, 0, SEEK_SET or die $!;
flock DAT, LOCK_SH or die $!;
{ local $/ = RECORD_SEPARATOR;
while (<DAT>) {
chomp;
my( $user, $pass ) = split(UNIT_SEPARATOR);
$user{$user} = $pass;
}
}
close DAT or warn $!;
# get new user/pass
my $cgi = new CGI;
if ( defined $cgi->param('user') ) {
my( $user, $pass ) = ( $cgi->param('user'), $cgi->param('pass') );
$$_ =~ tr/\x1e\x1f//d for \$user, \$pass;
$user{$user} = $pass;
}
# write to flat file db
open DAT, '>>file.txt' or die $!;
seek DAT, 0, SEEK_SET or die $!;
flock DAT, LOCK_EX or die $!;
truncate DAT, 0 or die $!;
{ local $\ = RECORD_SEPARATOR;
print DAT $_ . UNIT_SEPARATOR . $user{$_} for keys(%user);
}
close DAT or warn $!;
Mostly just for curiousity sake, but I would guess the encryption/ decryption logic would be somewhere in my cgi source. So using encryption would just be giving somebody another hoop to jump through to get to my data?
Maybe were just at the low end of security here, just making incremental steps towards some ultimate secure thing if there is such.
Jay5 using encryption would just be giving somebody another hoop to jump through
But the CGI source is not available to users of the site. The only thing they would be able to access is the encrypted data, which does them no good (assuming you've used an adaquately strong encryption scheme).
Yea I'm still a little green here. I forgot that. My thinking or train of mind is that everybody is seeing my CGI source and I realize this may not be true. That last repy, created a spark.
Bookmarks