Файл: EasyHost v2.0/system/htdocs/create/default.pl
Строк: 135
<?php
$system->error("Cookies must be enabled in order to complete the security check")
if ( $useSecurity and ! $system->cookie('security_code') );
$system->error("The security code you entered doesn't match the number in the image")
if ( $useSecurity and $system->cookie('security_code') ne crypt $system->param('security_code'), substr $system->param('security_code'), 0, 2);
$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 username you entered has been reserved') if (-e $system->config('root_dir').lc($system->param('username')));
$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'));
}
$system->error('The category field is require') if ($system->service->config('category_required') == 1 && $system->param('category') < 1);
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);
}
my $status = ($system->service->config('approval_method') eq 'none') ? 1 : '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->service->config('package_default'),$system->param('category') || '0',$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;
if ($system->service->config('approval_method') eq 'email')
{
my $temp = undef;
srand(time);
for (my $i = 1; $i <= 10; $i++)
{
$temp .= int(rand(9)) || '0';
}
$system->db->do('INSERT INTO users_config VALUES (?,?,?)',undef,$user->id,'validate',$temp);
}
$user->copy;
$user->notice('user_create','has created an account');
$system->redirect('finish');
?>