Esempio n. 1
0
function check_page_path($path, $prismic, $app)
{
    $page_uid = check_page_path1($path, $prismic);
    if ($page_uid == null) {
        $redirect_url = redirect_path($path, $prismic);
        if ($redirect_url != null) {
            $app->response->redirect($redirect_url);
        }
        if ($redirect_url == null) {
            not_found($app);
        }
    }
    return $page_uid;
}
Esempio n. 2
0
 /**
  * Показать форму регистрации
  * и при случае заполнения зарегистрировать нового пользователя
  *
  * @return void
  */
 public function register()
 {
     exit;
     // not yet
     $data = array();
     $this->load->helper('captcha');
     $random = md5(mt_rand(time() - 60000, time()));
     $thrash = array('o', 0, 'i', 8, 'B', 9, 'G', 0);
     $random = str_ireplace($thrash, '', $random);
     $vals = array('word' => substr($random, 0, 4), 'img_path' => './captcha/', 'img_url' => '/captcha/', 'img_width' => 120, 'img_height' => 40, 'expiration' => 7200);
     #            'font_path'	 => BASEPATH.'fonts/ARIALN.TTF',
     $cap = create_captcha($vals);
     $data['captcha'] = $cap;
     // получили параметры пользователя возможно из запроса или же остались что были
     $params = array('id', 'login', 'new_password', 'email');
     $user = params($params);
     $data['data'] = $user;
     $this->load->library('form_validation');
     $config = array(array('field' => 'login', 'label' => 'Логин', 'rules' => 'required|trim|alpha_numeric|callback_login_check'), array('field' => 'new_password', 'label' => 'Пароль', 'rules' => 'required|trim|min_length[6]'), array('field' => 'email', 'label' => 'E-mail', 'rules' => 'required|max_length[128]|valid_email|trim'));
     $this->form_validation->set_rules($config);
     if ($this->form_validation->run($this) === FALSE) {
         $this->template->render_to('content', $this->view . 'register', $data);
     } else {
         // регистрация
         // если есть аватар попробуем его загрузить и показать
         if (!empty($_FILES['avatar']['name'])) {
             // если есть изображение пробуем загрузить, откорректировать и сделать превью
             try {
                 //                    if( !empty($user['image']) ) $this->user->delete_file( 'avatar', $user['id'] );
                 $this->user->upload('avatar')->resize_image(array('width' => $this->settings['avatar_width'], 'height' => $this->settings['avatar_height'], 'adaptive' => TRUE));
                 $user['avatar'] = $this->user->file_name;
                 // удалим старое + превью
             } catch (Exception $e) {
                 set_flash_error($e->getMessage());
                 redirect_path('user/register');
                 return;
             }
         }
         //            $user['activate_code'] = sha1( mt_rand( time()-666000, time()) );
         $user['id'] = $this->user->save($user);
         /*
                     $this->load->library('email');
                     $s = &$this->settings;
         
                     $this->email->from( $s['email'], $s['name'] );
                     $this->email->to( $user['email'] );
         
                     $this->email->subject('Регистрация на сайте '.$s['name']);
                     $this->email->message("
         Спасибо вам за регистрацию, дорогой {$user['fio']}!
         
         Вы можете подтвердить своё желание зарегистироваться пройдя по ссылке
         http://{$s['url']}/user/action.activate.id.{$user['id']}.code.{$user['activate_code']}
         
                     ");
         
                     $this->email->send();
         */
         set_flash_ok('Пользователь успешно зарегистрирован, активируйте его');
         redirect('user/index');
     }
     $this->draw();
 }