Changeset 7495 for trunk/register.php


Ignore:
Timestamp:
Oct 30, 2010, 1:32:11 PM (14 years ago)
Author:
rvelices
Message:

feature 1915: add protection on user registration against robots

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/register.php

    r6363 r7495  
    4141if (isset($_POST['submit']))
    4242{
     43  if (!verify_ephemeral_key(@$_POST['key']))
     44  {
     45                set_status_header(403);
     46    array_push($errors, 'Invalid/expired form key');
     47  }
     48
    4349  if ($_POST['password'] != $_POST['password_conf'])
    4450  {
     
    4753
    4854  $errors =
    49       register_user(htmlspecialchars($_POST['login'],ENT_COMPAT,'utf-8'),
     55      register_user($_POST['login'],
    5056                    $_POST['password'],
    5157                    $_POST['mail_address'],
     
    5965    redirect(make_index_url());
    6066  }
     67        $registration_post_key = get_ephemeral_key(2);
     68}
     69else
     70{
     71        $registration_post_key = get_ephemeral_key(6);
    6172}
    6273
    63 $login = !empty($_POST['login'])?$_POST['login']:'';
    64 $email = !empty($_POST['mail_address'])?$_POST['mail_address']:'';
     74$login = !empty($_POST['login'])?htmlspecialchars(stripslashes($_POST['login'])):'';
     75$email = !empty($_POST['mail_address'])?htmlspecialchars(stripslashes($_POST['mail_address'])):'';
    6576
    6677//----------------------------------------------------- template initialization
     
    7586$template->assign(array(
    7687  'U_HOME' => make_index_url(),
    77 
     88        'F_KEY' => $registration_post_key,
    7889  'F_ACTION' => 'register.php',
    79   'F_LOGIN' => htmlspecialchars($login, ENT_QUOTES, 'utf-8'),
    80   'F_EMAIL' => htmlspecialchars($email, ENT_QUOTES, 'utf-8')
     90  'F_LOGIN' => $login,
     91  'F_EMAIL' => $email
    8192  ));
    8293
Note: See TracChangeset for help on using the changeset viewer.