Ejemplo n.º 1
0
 public function LoginProcess()
 {
     global $DB, $GLOB;
     if (isset($_REQUEST['user_id']) && $_REQUEST['user_id'] != "" && isset($_REQUEST['user_pass']) && $_REQUEST['user_pass'] != "") {
         $userID = $_REQUEST['user_id'];
         $userPwd = md5($_REQUEST['user_pass']);
     } else {
         $out = new HtmlOutput();
         $out->Login();
         exit;
     }
     if ($data = $DB->query("SELECT * FROM member WHERE account='{$userID}'")) {
         $data = $data[0];
         if ($userPwd == $data['password']) {
             if ($data['active_status'] == '0') {
                 //chua kich hoat
                 $GLOB->login_status = "Tai khoan chua kich hoat, vui long lien he admin";
                 $out = new HtmlOutput();
                 $out->Login();
                 exit;
             } else {
                 //ok
                 $_SESSION['logined'] = true;
                 $_SESSION['acc_type'] = $data['acc_type'];
                 $_SESSION['member'] = $data['account'];
                 $_SESSION['member_id'] = $data['id'];
                 $_SESSION['member_svgv'] = $data['svgv'];
                 if ($data['acc_type'] == "1" || $data['acc_type'] == "2") {
                     $out = new HtmlOutput();
                     $out->AdminMainPage();
                     exit;
                 }
                 if ($data['acc_type'] == "3") {
                     $out = new HtmlOutput();
                     $out->Home();
                     exit;
                 }
             }
         } else {
             $GLOB->login_status = "Wrong password";
             $out = new HtmlOutput();
             $out->Login();
             exit;
         }
     } else {
         $GLOB->login_status = "{$userID}: Account not found";
         $out = new HtmlOutput();
         $out->Login();
         exit;
     }
     return;
 }
Ejemplo n.º 2
0
 public function User()
 {
     global $USER;
     switch ($_REQUEST['action']) {
         case 'login':
             if (isset($_SESSION['logined'])) {
                 $this->HomePage();
             } else {
                 $out = new HtmlOutput();
                 $out->Login();
                 exit;
             }
             break;
         case 'borrowlist':
             if (isset($_SESSION['logined'])) {
                 $out = new HtmlOutput();
                 $out->UserBorrowList();
                 exit;
             } else {
                 $out = new HtmlOutput();
                 $out->Login();
                 exit;
             }
             break;
         case 'info':
             if (isset($_SESSION['logined'])) {
                 $out = new HtmlOutput();
                 $out->UserInformation();
                 exit;
             } else {
                 $out = new HtmlOutput();
                 $out->Login();
                 exit;
             }
             break;
         case 'change_password':
             if (isset($_SESSION['logined'])) {
                 $out = new HtmlOutput();
                 $out->UserChangePassword();
                 exit;
             } else {
                 $out = new HtmlOutput();
                 $out->Login();
                 exit;
             }
             break;
         case 'change_password_process':
             if (isset($_SESSION['logined'])) {
                 if ($USER->UserChangePasswordProcess()) {
                     $out = new HtmlOutput();
                     $out->UserChangePassword('<i class="fa fa-check"></i> Doi mat khau thanh cong');
                     exit;
                 } else {
                     $out = new HtmlOutput();
                     $out->UserChangePassword('<i class="fa fa-exclamation-circle"></i> Doi mat khau that bai');
                     exit;
                 }
             } else {
                 $out = new HtmlOutput();
                 $out->Login();
                 exit;
             }
             break;
         case 'update_info':
             if (isset($_SESSION['logined'])) {
                 if ($USER->InformationUpdate()) {
                     $out = new HtmlOutput();
                     $out->UserInformation('<i class="fa fa-check"></i> Cap nhat thong tin thanh cong');
                     exit;
                 } else {
                     $out = new HtmlOutput();
                     $out->UserInformation('<i class="fa fa-exclamation-circle"></i> Cap nhat thong tin that bai, vui long thu lai');
                     exit;
                 }
             } else {
                 $out = new HtmlOutput();
                 $out->Login();
                 exit;
             }
             break;
         case 'register':
             if (isset($_SESSION['logined'])) {
                 $this->HomePage();
             } else {
                 $out = new HtmlOutput();
                 $out->Register();
                 exit;
             }
             break;
         case 'register_process':
             if (isset($_SESSION['logined'])) {
                 $this->HomePage();
             } else {
                 $USER->RegisterProcess();
             }
             break;
         case 'forget_pass':
             if (isset($_SESSION['logined'])) {
                 $this->HomePage();
             } else {
                 $out = new HtmlOutput();
                 $out->FogetPassword();
                 exit;
             }
             break;
         case 'login_process':
             if (isset($_SESSION['logined'])) {
                 $this->HomePage();
             } else {
                 $USER->LoginProcess();
             }
             break;
         case 'logout':
             session_destroy();
             header("Location: " . ROOT_DOMAIN);
             exit;
             break;
         default:
             $this->HomePage();
             break;
     }
 }