Skip to content

Commit

Permalink
Update contact.pl
Browse files Browse the repository at this point in the history
let only registered users send a message
  • Loading branch information
efiabruni committed Feb 3, 2014
1 parent 62f82df commit 27f7f5e
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions blog/contact.pl
Expand Up @@ -4,15 +4,47 @@
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 '')
{
print '<br />'.$locale{$lang}->{necessary};
$do = 0;
}
#see if user is registered
open(FILE, "<$config_commentsDatabaseFolder/users.$config_dbFilesExtension.dat");
my $data = '';
while(<FILE>)
{
$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 '<br />'.$locale{$lang}->{compass};
}
last;
}
}
if($hasPosted == 0)
{
print "Please <a href='?do=register'>register</a> before you comment";
$do = 0;
}

#check captcha if indicated
if($config_commentsSecurityCode == 1)
{
Expand Down Expand Up @@ -75,9 +107,12 @@
<td>'.$locale{$lang}->{csubject}.'</td>
<td><input name=title type=text id=title></td>
</tr><tr>
<td>'.$locale{$lang}->{name}.'</td>
<td>Username</td>
<td><input name=name type=text id=name></td>
</tr><tr>
<td>Password <href="?do=register">Register</a></td>
<td><input name="pass" type="password" id="pass"></td>
</tr><tr>
<td>'.$locale{$lang}->{email}.'</td>
<td><input name=email type=text id=email></td>
</tr><tr><td>'.$locale{$lang}->{cmessage}.'</td>
Expand Down Expand Up @@ -108,4 +143,4 @@
print'<tr>
<td><input name="process" type="hidden" id="process" value="contact"></td>
<td><input type="submit" name="Submit" value="'.$locale{$lang}->{send}.'"></td>
</tr></table></form>';
</tr></table></form>';

0 comments on commit 27f7f5e

Please sign in to comment.