From 27f7f5ec316f9a6d19b9cc01afc95d1f958adbc6 Mon Sep 17 00:00:00 2001 From: efiabruni Date: Sun, 2 Feb 2014 22:08:13 -0200 Subject: [PATCH] Update contact.pl let only registered users send a message --- blog/contact.pl | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/blog/contact.pl b/blog/contact.pl index 3a4ff3a..6962d84 100644 --- a/blog/contact.pl +++ b/blog/contact.pl @@ -4,8 +4,10 @@ if (r('process')eq 'contact'){ my $title = r('title'); my $author = r('name'); + my $pass = r('pass'); my $email = r('email'); my $message = r('content'); + my $hasPosted = 0; my $do = 1; if($title eq '' || $author eq '' || $message eq ''|| $email eq '') @@ -13,6 +15,36 @@ print '
'.$locale{$lang}->{necessary}; $do = 0; } + #see if user is registered + open(FILE, "<$config_commentsDatabaseFolder/users.$config_dbFilesExtension.dat"); + my $data = ''; + while() + { + $data.=$_; + } + close(FILE); + + my @users = split(/"/, $data); + foreach(@users) + { + my @data = split(/'/, $_); + if($author eq $data[0]) + { + $hasPosted = 1; + if(crypt($pass, $config_randomString) ne $data[1]) + { + $do = 0; + print '
'.$locale{$lang}->{compass}; + } + last; + } + } + if($hasPosted == 0) + { + print "Please register before you comment"; + $do = 0; + } + #check captcha if indicated if($config_commentsSecurityCode == 1) { @@ -75,9 +107,12 @@ '.$locale{$lang}->{csubject}.' -'.$locale{$lang}->{name}.' +Username +Password Register + + '.$locale{$lang}->{email}.' '.$locale{$lang}->{cmessage}.' @@ -108,4 +143,4 @@ print' -'; \ No newline at end of file +';