php defined SYSPATH or die No direct script access class Controller_Si

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Signup extends Controller_Template {
public function action_index()
{
$errors = null;
if($_POST) {
$_POST = Arr::map('trim', $_POST);
$post = Validation::factory($_POST);
$post->rule('login', 'not_empty');
$post->rule('login', 'alpha_dash', array(':value', TRUE));
$post->rule('login', 'min_length', array(':value', 3));
$post->rule('login', 'max_length', array(':value', 20));
$post->rule('email', 'not_empty');
$post->rule('email', 'email');
$post->rule('password', 'not_empty');
$post->rule('password', 'min_length', array(':value', 8));
$post->rule('confirm', 'not_empty');
$post->rule('confirm', 'matches', array(':validation', 'confirm', 'password'));
if($post->check()) {
/* тут вызвать модель для записи юзера */
return true;
} else $errors = $post->errors('signup');
}
$content = View::factory('signup');
$content->errors = $errors;
$this->template->title = 'Регистрация';
$this->template->content = $content;
}
}