Beispiel #1
0
 public function action_initRegister()
 {
     if ($this->_post_data_) {
         $response = Arr::extract($this->_post_data_, ['email', 'username', 'password', 'password_complete']);
         foreach ($response as $data => $value) {
             if (empty($value)) {
                 $this->_response_['error'] = Kohana::message('register/init', 'fill_error');
                 return;
             }
         }
         if (!preg_match('/^([a-z0-9_\\.\\-]{1,20})@([a-z0-9\\.\\-]{1,20})\\.([a-z]{2,4})/is', $response['email'])) {
             $this->_response_['error'] = Kohana::message('register/init', 'error_email_format');
             return;
         }
         $user = Model\UsersQuery::create()->findOneByEmail($response['email']);
         if ($user) {
             $this->_response_['error'] = Kohana::message('register/init', 'email_exists');
             return;
         }
         if (!preg_match('/^[абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯЇїіІєЄёЁa-zA-Z0-9]+$/', $response['username'])) {
             $this->_response_['error'] = Kohana::message('register/init', 'error_username_format');
             return;
         }
         if (strlen($response['password']) < 6 || strlen($response['password']) > 32) {
             $this->_response_['error'] = Kohana::message('register/init', 'error_password_length');
             return;
         }
         if ($response['password'] !== $response['password_complete']) {
             $this->_response_['error'] = Kohana::message('register/init', 'error_password_not_match');
             return;
         }
         $register = new Register();
         if ($register->init([$response])) {
             $this->_response_['success'] = Kohana::message('register/init', 'success');
         }
     }
 }
Beispiel #2
0
<?php

// loosewire ajax backend
require 'functions.php';
// settings
Register::$base = __FILE__;
Register::$upload_folder = 'uploads';
Register::$project_folder = 'projects';
// init register
Register::init();
// start response
Response::start(true);
// true for debug
// upload project
if (Request::is_type('upload')) {
    if ($result = Project::upload()) {
        Response::exit_with($result);
    } else {
        Response::exit_with(['error' => 'Error uploading file']);
    }
}
// list projects
if (Request::is_type('list')) {
    if ($result = Project::getlist()) {
        Response::exit_with($result);
    } else {
        Response::exit_with(['error' => 'Error fetching projects']);
    }
}
// list projects
if (Request::is_type('load', ['filename'])) {
Beispiel #3
0
        $user->set_id($id);
        $_SESSION['id'] = $id;
    }
    public function image_processing($user)
    {
        $this->instance->update_user_field($user->get_username(), 'picture', $user->get_image_name());
        $image = $user->get_image();
        new UploadPicture($image, $user->get_id());
        new CrateThumbnail('./user_pics/' . $user->get_image_name(), './user_pics/user_thumbnails/' . $user->get_image_name(), 100);
        header('Location: index.php?home');
    }
    public function init()
    {
        session_start();
        $registerView = new RegisterView();
        if (!isset($_SESSION['username'])) {
            $registerView->initView();
        } else {
            header('Location: http://date.me/index.php?home');
            exit;
        }
        if (isset($_POST['submit'])) {
            $user = $this->data_processing();
            $this->get_user_id($user);
            $this->image_processing($user);
        }
    }
}
$register = new Register();
$register->init();