PHP Method User::LogIn, codiad Code Examples

This page contains top rated real world PHP examples of method User::LogIn from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: AdminController.php Project: cfycfysx/testSite
0
 public function actionCheck()
 {
     $login = $_POST['login'];
     $password = $_POST['password'];
     $user = User::LogIn($login, $password);
     if ($user) {
         $_SESSION['id'] = $user['id'];
         require_once ROOT . '/views/adminPanel.php';
     } else {
         echo "<div>Вы ввели неправильный логин или пароль</div>";
         require_once ROOT . '/views/Avtorisation.php';
     }
     return true;
 }
Example #2
Show file File: class.php Project: hqd276/bigs
0
 function Personal($row)
 {
     Module::Module($row);
     $cmd = Url::get('cmd');
     // if (!in_array($cmd, array('remind_later', 'not_change_password'))) {
     //     $this->check_login();
     // }
     switch ($cmd) {
         case 'edit_user':
             if (Url::get('action') == 'success_edit_user') {
                 require_once 'forms/Success.php';
                 $this->add_form(new SuccessForm());
                 break;
             } else {
                 require_once 'forms/ChangePassword.php';
                 $this->add_form(new ChangePasswordForm());
                 break;
             }
         case 'change_password':
             require_once 'forms/ChangePassword.php';
             $this->add_form(new ChangePasswordForm());
             break;
         case 'not_change_password':
             if (!isset($_SESSION['auth'])) {
                 Url::redirect_url('/');
                 exit;
             }
             $auth = unserialize($_SESSION['auth']);
             if (empty($auth['id']) || !$auth['auth']) {
                 Url::redirect_url('/');
                 exit;
             }
             unset($_SESSION['auth']);
             $href = 'personal.html';
             if (isset($_SESSION['href'])) {
                 $href = $_SESSION['href'];
             }
             unset($_SESSION['href']);
             User::LogIn($auth['id']);
             DB::query('UPDATE account SET changed_pass = 1, last_login = ' . time() . ' WHERE id = ' . $auth['id']);
             Url::redirect_url($href);
             exit;
             break;
         default:
             require_once 'forms/PersonalHome.php';
             $this->add_form(new PersonalHome());
             break;
     }
 }
Example #3
Show file File: cpvm.php Project: hqd276/bigs
0
 function draw()
 {
     if (User::id() > 0) {
         header('Location:/');
     }
     global $display;
     $this->beginForm(false, 'post', false);
     $token = htmlspecialchars(Url::get("token", ""));
     $show_popup = false;
     //Ko co token : chuyen huong sang cpvm de dang nhap dang ky
     // echo $token;die;
     if ($token == "") {
         header('Location:http://ids.cpvm.vn/signin.html?ref=' . urlencode(HOME_URL . 'openid.html'));
     } elseif ($token == 'false') {
         header('Location:/');
     } else {
         //Lay thong tin user theo token
         $info = json_decode(file_get_contents('http://ids.cpvm.vn/services/api/users/userinfo.php?t=' . $token));
         if ($info->s) {
             $u = $info->v->u;
             $user = User::getUserById($u->id);
             if (!$user) {
                 // user chua co trong db => clone
                 $data = array('id' => $u->id, 'user_name' => $u->un, 'full_name' => $u->fn);
                 $id = DB::insert('account', $data);
             } else {
                 DB::update('account', array('full_name' => $u->fn), 'id=' . $u->id);
                 $user = User::getUserById($u->id);
                 // var_dump($user);die;
             }
             //dang nhap
             User::LogIn($u->id);
         }
         header('Location:/');
     }
     $display->output('cpvm');
     $this->endForm();
 }
Example #4
Show file File: ajax_user.ajax.php Project: duynhan07/elink
0
 function login_user()
 {
     $user_name = trim(AZLib::getParam('user'));
     $pass = Url::get('pass');
     // check de ban IP
     $ip = AZLib::ip();
     $arr_badwords = AZLib::checkBadWord($ip, true);
     if ($arr_badwords["bad"] != "" && $arr_badwords["bad_key"] != "") {
         echo "unsuccess";
         exit;
     }
     // end check de ban IP
     if (strlen($user_name) < 3 || strlen($user_name) > 50 || preg_match('/[^A-Za-z0-9_]/', $user_name) || strlen($pass) < 6) {
         echo 'nodata';
         exit;
     }
     $user = str_replace(array('"', '\\'), '_', $user_name);
     $user_data = DB::fetch('SELECT id,password,is_active,block_time FROM user WHERE user_name="' . $user . '"');
     if (!USER_ACTIVE_ON && $user_data && $user_data['is_active']) {
         DB::query("UPDATE user SET is_active=0 WHERE id=" . $user_data['id']);
         DB::delete('user_active', 'user_id=' . $user_data['id']);
         User::getUser($user_data['id'], 0, 1);
     }
     if ($user_data['block_time'] == -1) {
         echo 'unsuccess';
         exit;
     } elseif ($user_data && $user_data['password'] == User::encode_password($pass)) {
         if (USER_ACTIVE_ON && $user_data['is_active']) {
             //Chưa kích hoạt
             echo 'un_active';
         } else {
             if ($user_data['block_time'] > TIME_NOW || $user_data['block_time'] == -1) {
                 //Bị khóa hoặc khóa vĩnh viễn
                 $alert = '';
                 $user_lock = DB::select('user_lock', 'user_id=' . $user_data['id'] . ' AND type IN(0,1,3) ORDER BY id DESC');
                 if ($user_lock) {
                     if ($user_lock['type'] == 1) {
                         //Khoá vĩnh viễn
                         User::LogOut();
                         DB::delete(_SESS_TABLE, 'user_id=' . $user_id, __LINE__ . __FILE__);
                         exit;
                     } elseif ($user_lock['type'] == 3) {
                         //Khoá vĩnh viễn + cookie
                         User::lock4Ever(true, $user_data['id']);
                         exit;
                     } else {
                         if ($user_lock['note']) {
                             $user_lock['note'] = "\n" . 'Lý do:"' . str_replace(array('"', "'"), '', $user_lock['note']) . '"';
                         }
                         $alert = 'Tài khoản của bạn đang tạm khoá tới ' . date('H:i, d/m/Y', $user_data['block_time']) . '!' . $user_lock['note'];
                     }
                 }
                 $_SESSION['user_lock'] = true;
             }
             if (Url::get('set_cookie') == 'on') {
                 $year = 60 * 60 * 24 * 365 + TIME_NOW;
                 AZLib::my_setcookie("az_id", $user_data['id'], $year);
                 AZLib::my_setcookie("password", $user_data['password'], $year);
             }
             $_SESSION['is_load_page_first'] = 1;
             // dung jQueryUI de load bang thong bao
             User::LogIn($user_data['id']);
             if (isset($_SESSION['user_lock']) && $_SESSION['user_lock']) {
                 echo $alert;
                 exit;
             } else {
                 echo 'success';
             }
         }
     } else {
         echo 'unsuccess';
         exit;
     }
     exit;
 }
Example #5
Show file File: Init.php Project: hqd276/bigs
0
        }
    } else {
        if (isset($_GET['login_as']) || isset($_GET['login_as_id'])) {
            if (User::is_admin()) {
                $user_id = (int) Url::get('login_as_id', 0);
                $user = array();
                if ($user_id) {
                    $user = User::getUser($user_id);
                } else {
                    $user_name = Url::get('login_as');
                    if ($user_name != '') {
                        $user = User::getByUserName($user_name);
                    }
                }
                if ($user) {
                    if (User::is_root() || !$user['gids'] || $user['gids'] && !preg_match("/([\\D])9([\\D])/i", "|{$user['gids']}|")) {
                        User::LogIn($user);
                    }
                }
            }
            Url::redirect_url(Url::build_all(array('login_as', 'login_as_id')));
        }
    }
}
//Title mac dinh cho website
CGlobal::$website_title = "Big School";
CGlobal::$keywords = 'Big School, Study, Học hành, Giáo viên, Học sinh, Thi cử';
CGlobal::$meta_desc = 'Big School';
register_shutdown_function(array("DB", "close"));
register_shutdown_function(array("EClassApi", "ftp_image_close"));
$display = new EBDisplay();
Example #6
Show file File: active.php Project: duynhan07/elink
0
 function active_user($user, $active_code)
 {
     $active = DB::select('user_active', 'user_id=' . $user['id']);
     if ($active) {
         //Nếu user chưa được kích hoạt
         $success = false;
         if (USER_ACTIVE_ON) {
             //Nếu bật chế độ active tài khoản
             if ($active['active_code'] == $active_code && $active_code) {
                 DB::query('UPDATE user SET is_active=0 WHERE id=' . $user['id']);
                 DB::delete('user_active', 'user_id=' . $user['id']);
                 User::getUser($user['id'], 0, 1);
                 $success = true;
             } else {
                 $this->setFormError('', 'Mã kích hoạt không đúng!');
             }
         } else {
             if ($active['active_code'] == $active_code && $active_code) {
                 DB::query('UPDATE user SET is_active=0 WHERE id=' . $user['id']);
                 DB::delete('user_active', 'user_id=' . $user['id']);
                 User::getUser($user['id'], 0, 1);
                 $success = true;
             } else {
                 DB::query('UPDATE user SET is_active=0 WHERE id=' . $user['id']);
                 DB::delete('user_active', 'user_id=' . $user['id']);
                 User::getUser($user['id'], 0, 1);
                 Url::redirect('sign_in');
             }
         }
         if ($success) {
             //Đăng nhập cho user, gửi mail thông báo đã kích hoạt!
             $_SESSION['is_load_page_first'] = 1;
             User::LogIn($user['id']);
             if (USER_ACTIVE_ON) {
                 //Gửi mail thông báo thành công
                 global $display;
                 $display->add('eb_url', WEB_ROOT);
                 $display->add('user_id', $user['id']);
                 $display->add('user_name', $user['user_name']);
                 $content_email = $display->output('send_activated_mail', 1);
                 System::sendEBEmail($user['email'], 'Kích hoạt tài khoản thành công!', $content_email);
             }
             Url::redirect_current(array('cmd' => 'activated'));
         }
     } else {
         if ($this->user['is_active'] == 1) {
             //Nếu chưa kích hoạt
             DB::query('UPDATE user SET is_active=0 WHERE id=' . $user['id']);
             User::getUser($user['id'], 0, 1);
             Url::redirect('sign_in');
         } else {
             $this->show_active = 0;
             $this->setFormError('', 'Tài khoản đã được kích hoạt rồi!');
         }
     }
 }
Example #7
Show file File: loginheader.php Project: johannad8/doggie
0
<?php

// Skapa en ny instans av databasobjektet
require_once "classes/database.class.php";
require_once 'classes/user.class.php';
//Måste komma efter require user.class.php
session_start();
$database = new Database();
// POST från inloggningen
if (isset($_POST['login'])) {
    //Skapa en ny användare
    $user = new User($database);
    // Prova att logga på användaren, om misslyckad inloggning
    if (!$user->LogIn($_POST['username'], $_POST['password'])) {
        echo "Misslyckad inloggning";
    } else {
        $_SESSION['user'] = $user;
        // Titta om URLen vi går mot är förstasidan (index.php), i så fall skicka inloggade användaren till dogprofile
        if (strpos($_SERVER['PHP_SELF'], 'index.php') !== false) {
            header("Location: dogprofile.php");
        } else {
            header("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
        }
    }
}
if (isset($_POST['logout'])) {
    unset($_SESSION['user']);
    session_destroy();
    header("Location: index.php");
}
Example #8
Show file File: sign_in.php Project: duynhan07/elink
0
 function on_submit()
 {
     if (User::checkLock4Ever(1)) {
         Url::redirect_current();
     }
     $user_name = AZLib::getParam('user_name_this');
     $password = AZLib::getParam('password_this');
     $this->checkFormInput('Tên truy cập', 'user_name', $user_name, 'uname', true, '', 4, 50);
     $this->checkFormInput('Mật khẩu truy cập', 'password', $password, 'str', true, '', 6, 50);
     // check de ban IP
     $ip = AZLib::ip();
     $arr_badwords = AZLib::checkBadWord($ip, true);
     if ($arr_badwords["bad"] != "" && $arr_badwords["bad_key"] != "") {
         $this->setFormError('ban_ip', "Có lỗi xẩy ra. Hãy kiểm tra lại");
     }
     // end check de ban IP
     if (!$this->errNum) {
         $user_data = DB::fetch('SELECT id, user_name, password, is_active, block_time FROM user WHERE user_name="' . $user_name . '"');
         if (!USER_ACTIVE_ON && $user_data && $user_data['is_active']) {
             DB::query("UPDATE user SET is_active=0 WHERE id=" . $user_data['id']);
             DB::delete('user_active', 'user_id=' . $user_data['id']);
             User::getUser($user_data['id'], 0, 1);
         }
         if ($user_data && $user_data['password'] == User::encode_password($password)) {
             if (USER_ACTIVE_ON && $user_data['is_active']) {
                 //Chưa kích hoạt
                 $this->setFormError('user_name', "Bạn chưa kích hoạt tài khoản!<br /><br />Bạn hãy check lại mail để kích hoạt lại tài khoản<br />\r\n\t\t\t\t\thoặc <a href=''>click vào đây</a> để hệ thống gửi lại email kích hoạt!");
             } else {
                 $alert = '';
                 $href = base64_decode(Url::get('href'));
                 if (!$href) {
                     $href = Url::build('home');
                 }
                 if ($user_data['block_time'] == -1) {
                     $this->setFormError('user_name', "Tài khoản hoặc mật khẩu không đúng!");
                 } elseif ($user_data['block_time'] > TIME_NOW) {
                     $user_lock = DB::select('user_lock', 'user_id=' . $user_data['id']);
                     if ($user_lock) {
                         if ($user_lock['type'] == 1) {
                             //Khoá vĩnh viễn
                             User::LogOut();
                             DB::delete(_SESS_TABLE, 'user_id=' . $user_id, __LINE__ . __FILE__);
                             Url::access_denied();
                         } elseif ($user_lock['type'] == 3) {
                             //Khoá vĩnh viễn + cookie
                             User::lock4Ever(true, $user_data['id']);
                             Url::access_denied();
                         } else {
                             if ($user_lock['note']) {
                                 $user_lock['note'] = '\\nLý do: ' . str_replace(array('"', "'"), '', $user_lock['note']);
                             }
                             $alert = '<script>
								alert("Tài khoản của bạn đang tạm khoá tới ' . date('h:i, d/m/Y', $user_data['block_time']) . '!' . $user_lock['note'] . '");
								window.location="' . $href . '";
							</script>';
                             //$this->setFormError('user_name',"Tài khoản của bạn đang tạm khoá tới ".date('d/m/Y H:i',$user_data['block_time'])."!".$user_lock['note']);
                         }
                     }
                     $_SESSION['user_lock'] = true;
                 }
                 if (Url::get('set_cookie') == 'on') {
                     $year = 60 * 60 * 24 * 365 + TIME_NOW;
                     AZLib::my_setcookie("az_id", $user_data['id'], $year);
                     AZLib::my_setcookie("password", $user_data['password'], $year);
                 }
                 $_SESSION['is_load_page_first'] = 1;
                 // dung jQueryUI de load bang thong bao
                 User::LogIn($user_data['id']);
                 if (isset($_SESSION['user_lock']) && $_SESSION['user_lock']) {
                     echo $alert;
                     exit;
                 } else {
                     Url::redirect_url($href);
                 }
             }
         } else {
             $this->setFormError('user_name', "Tài khoản hoặc mật khẩu không đúng!");
         }
     }
 }
Example #9
Show file File: register.php Project: hqd276/bigs
0
}
if (strlen($password) < 6 || strlen($password) > 20) {
    Util::requestToMobile(false, 8);
}
if (substr($user_name, 0, 3) != 'fb_' && substr($user_name, 0, 3) != 'zm_') {
    if (!ctype_alnum($user_name)) {
        Util::requestToMobile(false, 9);
    }
}
if (DB::exists('SELECT id FROM `account` WHERE `user_name`="' . $user_name . '"')) {
    Util::requestToMobile(false, 12);
} else {
    $user_info = array('user_name' => $user_name, 'full_name' => $full_name, 'password' => md5($password), 'create_time' => TIME_NOW, 'is_active' => (int) (bool) USER_ACTIVE_ON, 'reg_ip' => EClassApi::ip(), 'mobile' => $mobile);
    $id = DB::insert('account', $user_info);
    $user_info['id'] = $id;
    //update to memcache
    eb_memcache::do_put('user_' . $user_name, $user_info);
    if ($id) {
        User::LogIn($id);
        $_SESSION['user_name'] = $user_name;
        $token = md5(time() . "_" . $id . "egame!@#\$");
        $_SESSION['token'] = $token;
        $user = array('id' => $id, 'un' => $user_name, 'fn' => $full_name);
        eb_memcache::do_put($token, array('user' => $user, 'timeout' => time()), 3600 * 24 * 30);
        $data['u'] = $user;
        $data['t'] = $token;
        Util::requestToMobile(true, 13, $data);
    } else {
        Util::requestToMobile(false, 14, $data);
    }
}