Файл: EasyHost v2.0/system/htdocs/admin/users/create.pl
Строк: 112
<?php
$system->error('This feature has been disabled in demo mode') if $system->config('demo');
$system->error('The username field is required') if (!$system->param('username'));
$system->error('The username field contains invalid characters') if ($system->param('username') !~ /^[w-.]+$/i );
$system->error('The username field must be between '.$system->config('username_min').' to '.$system->config('username_max').' characters in length') if (length $system->param('username') < $system->config('username_min') || length $system->param('username') > $system->config('username_max'));
$system->error('The username you entered has already been taken') if ($system->db->selectrow_array('SELECT id FROM users WHERE name = ?',undef,lc $system->param('username')) > 0);
$system->error('The password field is required') if (!$system->param('password'));
$system->error('The password field must be between '.$system->config('password_min').' to '.$system->config('password_max').' characters in length') if (length $system->param('password') < $system->config('password_min') || length $system->param('password') > $system->config('password_max'));
$system->error('The password field must not be the same as your username') if ($system->param('password') eq $system->param('username'));
$system->error('The password field doesn't match what you re-typed') if ($system->param('password') ne $system->param('password2'));
$system->error('The e-mail address field is required') if (!$system->param('email'));
$system->error('The e-mail address field contains invalid characters') if ($system->param('email') !~ /.+@[w-.]{4,}/);
if ($system->service->config('distinct_email') > 0)
{
my $count = $system->db->selectrow_array('SELECT COUNT(*) FROM users WHERE email = ?',undef,$system->param('email'));
$system->error('The e-mail address you entered has already been assigned to '.$count.' account(s)') if ($count >= $system->service->config('distinct_email'));
}
if ($system->service->config('data_website') eq 'required')
{
$system->error('The website title field is required') if (length $system->param('data_title') == 0);
$system->error('The website description field is required') if (length $system->param('data_description') == 0);
}
if ($system->service->config('data_contact') eq 'required')
{
$system->error('The contact name field is required') if (length $system->param('data_contact') == 0);
$system->error('The phone number field is required') if (length $system->param('data_phone') == 0);
}
if ($system->service->config('data_address') eq 'required')
{
$system->error('The address field is required') if (length $system->param('data_address') == 0);
$system->error('The city field is required') if (length $system->param('data_city') == 0);
$system->error('The country field is required') if (length $system->param('data_country') == 0);
$system->error('The province field is required') if ($system->param('data_country') eq 'CA' && length $system->param('data_province') == 0);
$system->error('The state field is required') if ($system->param('data_country') eq 'US' && length $system->param('data_state') == 0);
$system->error('The zip/postal code field is required') if (length $system->param('data_zip_code') == 0);
}
$system->db->do('INSERT INTO users (name,password,email,package_id,category_id,status,date_created,date_online) VALUES (?,?,?,?,?,?,NOW(),NOW())',undef,lc($system->param('username')),$system->param('password'),$system->param('email'),$system->param('package') || $system->service->config('package_default'),$system->param('category') || '0',$system->param('status') || '0');
my $user = EasyHost::User->new($system->db->selectrow_array('SELECT id FROM users ORDER BY id DESC LIMIT 1'));
my $insert = $system->db->prepare('INSERT INTO users_data VALUES (?,?,?)');
foreach (grep { lc(substr($_,0,5)) eq 'data_' && length $system->param($_) > 0 } $system->param)
{
my $name = substr $_,5;
$insert->execute($user->id,$name,$system->param($_));
}
$insert->finish;
$user->copy;
$user->notice('user_create','has created an account');
$system->redirect;
?>