示例#1
0
文件: user.php 项目: ak826843/bmf
 /**
  * Попробуем залогинется переданным логином и паролем
  * 
  * @param   string $login
  * @param   string $password
  * @return bool 
  */
 public function try_login($login, $password, $not_crypted = TRUE, $remember = TRUE)
 {
     if ($not_crypted) {
         $user = $this->where('login', $login)->find(NULL, 1);
         if (empty($user)) {
             $this->error = 3;
             return FALSE;
         }
         if ($user['banned'] == 1) {
             $this->error = 4;
             return FALSE;
         }
         // если уже и так шифрованно, то не надо
         $new_password = $not_crypted ? $this->make_password($password, $user['salt']) : $password;
         if ($user['password'] != $new_password) {
             $this->error = 1;
             return FALSE;
         }
     }
     $this->user = $user;
     $this->session->set_userdata('user', $user);
     log_message('debug', TextDump($this->user));
     if ($remember) {
         setcookie('login', $this->user['login'], time() + 12 * 60 * 60 * 24 * 30, '/', '.' . $_SERVER['HTTP_HOST']);
         setcookie('password', $this->user['password'], time() + 12 * 60 * 60 * 24 * 30, '/', '.' . $_SERVER['HTTP_HOST']);
     }
     // обновим дату визита пользователя на текущую
     $this->db->set('logined_at', 'NOW()', FALSE)->where('id', $user['id'])->update($this->table);
     return TRUE;
 }
示例#2
0
function Dump(&$Var, $full = false)
{
    if ($full) {
        fullDump($Var);
        return;
    }
    if ((is_array($Var) || is_object($Var)) && count($Var)) {
        echo "<pre>\n", TextDump($Var), "</pre><br>\n";
    } else {
        echo "<tt>", TextDump($Var), "</tt>\n";
    }
}
示例#3
0
function Dump(&$Var, $need_return = FALSE)
{
    $out = '';
    if ((is_array($Var) || is_object($Var)) && count($Var)) {
        $out .= "<pre>\n" . TextDump($Var) . "</pre>\n";
    } else {
        $out .= "<tt>" . TextDump($Var) . "</tt>\n";
    }
    if ($need_return) {
        return $out;
    }
    echo $out;
}
/**
 * Сохраним наш лог действий пользователя
 *
 * @param mixed|string  $log
 * @param string        $comment
 */
function log_action($log = '', $comment = '')
{
    $site = CI()->config->item('site');
    if (!$site['log_action']) {
        return;
    }
    if (!is_string($log)) {
        $log = TextDump($log);
    }
    $debug = debug_backtrace();
    #dump( $debug );
    $user = CI()->user_mod->get_all();
    $data = array('date_at' => (string) now2mysql(), 'login' => (string) $user['login'], 'file' => (string) $debug[0]['file'], 'func' => (string) $debug[1]['function'], 'line' => (string) $debug[0]['line'], 'log' => (string) $log, 'comment' => (string) $comment);
    CI()->log_mod->save($data);
}