public static function init()
 {
     $username = get('username');
     $password = get('password');
     if (!$username) {
         exit('Пожалуйста, укажите имя для пользователя.');
     }
     if (!$password) {
         exit('Пожалуйста, укажите пароль пользователю.');
     }
     if (string::length($password) < 6) {
         exit('Ваш пароль не может быть менее 6 символов.');
     }
     $user = users::get_by_name($username);
     if (!$user) {
         exit('Данного пользователя не существует.');
     }
     if (!crypt::is_valid($password, $user->hash, $user->salt)) {
         exit('Указанный вами пароль не совпадает с тем, что был указан при регистрации.');
     }
     $is_authorized = template_session::login($user->id);
     if (!$is_authorized) {
         exit('Нарушение логической цепи: авторизация не произведена.');
     }
 }
 public static function progress($current, $total, $cells = 10, $cell = '#')
 {
     $current = str_pad($current, string::length($total), '0', STR_PAD_LEFT);
     $total = str_pad($total, string::length($total), '0', STR_PAD_LEFT);
     $percent = round($current / $total * 100, 2);
     $passed = ceil($percent / (100 / $cells));
     $progress = str_repeat($cell, $passed);
     $progressbar = '[' . str_pad($progress, $cells, ' ', STR_PAD_RIGHT) . ']';
     static::write('(' . $current . '/' . $total . ') ' . $progressbar . ' ' . str_pad($percent, 5, ' ', STR_PAD_LEFT) . '%', false, true);
 }
 public static function init()
 {
     $username = get('username');
     $password = get('password');
     //$role_id = get('role_id');
     if (!$username) {
         exit('Пожалуйста, укажите имя для пользователя.');
     }
     if (!$password) {
         exit('Пожалуйста, укажите пароль пользователю.');
     }
     if (string::length($password) < 6) {
         exit('Ваш пароль должен быть длиной 6 или более символов.');
     }
     if (users::is_exists($username)) {
         exit('Данный пользователь уже существует. Попробуйте указать другое имя.');
     }
     $user_id = users::add($username, $password, RUDE_ROLE_USER);
     if (!$user_id) {
         exit('Произошла непредвиденная ошибка. Пожалуйста, обратитесь к администратору сайта и расскажите после каких действий вы увидели данное сообщение.');
     }
     settings::add($user_id);
     template_session::login($user_id);
 }
 public static function to_capital($string)
 {
     return string::to_uppercase(char::first($string)) . string::read($string, string::length($string) - 1, 1);
 }