Beispiel #1
0
 public static function check($token)
 {
     $tokenName = TOKEN_NAME;
     if (session::exist($tokenName) && $token === session::get($tokenName)) {
         session::delete($tokenName);
         return TRUE;
     }
     return FALSE;
 }
Beispiel #2
0
 public static function loginAuth($from)
 {
     //check token remember me
     //check session
     $db = new database(DBTYPE, DBHOST, DBNAME, DBUSER, DBPASS);
     if (cookie::exists(TOKEN_NAME)) {
         $token = cookie::get(TOKEN_NAME);
         $checkExist = user::checkExist("users_session", "token = '{$token}'");
         if ($checkExist) {
             $sessionData = $db->select("users_session", "*", "token = '{$token}'", "fetch");
             $agent_id = $sessionData['agent_id'];
             user::login($agent_id);
             $userData = $db->select("user_accounts", "*", "agent_id = '{$agent_id}'", "fetch");
             if ($from == 'login') {
                 self::accountCheck($userData);
                 redirect::to("dashboard");
             } else {
                 self::accountCheck($userData);
             }
         } else {
             user::logout();
         }
     } elseif (session::exist(AGENT_LOGIN_SESSION) && session::exist(AGENT_SESSION_NAME)) {
         $agent_id = session::get(AGENT_SESSION_NAME);
         $check_agentExist = user::checkExist("user_accounts", "agent_id = '{$agent_id}'");
         $userData = $db->select("user_accounts", "*", "agent_id = '{$agent_id}'", "fetch");
         if (!$check_agentExist) {
             user::logout();
         }
         user::login($agent_id);
         if ($from == 'login') {
             self::accountCheck($userData);
             redirect::to("dashboard");
         } else {
             self::accountCheck($userData);
         }
     } else {
         if ($from != 'login') {
             user::logout();
         }
     }
 }
Beispiel #3
0
 function __construct()
 {
     session::init();
     $this->breadcrumb = new breadcrumb();
     $this->view = new view();
     $this->_userProfileImages = IMAGES_PATH . "user-default.png";
     if (session::exist(AGENT_SESSION_NAME) and session::exist(AGENT_LOGIN_SESSION)) {
         $agent_id = session::get(AGENT_SESSION_NAME);
         $userData = new user();
         //            USERDATA
         $this->_userData = $userData->getUserData('agent_id', $agent_id);
         $user = $this->_userData;
         //            USER ACC. TYPE
         $userAccType = user::getAccType($user['acc_type']);
         $this->_userAccType = $userAccType['label'];
         //            PROFILE IMAGE
         $profileImageExist = user::checkExist("user_images", "agent_id = '{$agent_id}' AND profile = '1'");
         if ($profileImageExist) {
             $image = user::getUserImages($agent_id, TRUE);
             $this->_userProfileImages = IMAGES_PATH . "users/" . $image['filename'];
         }
         //            AVAILABLE COMMISSION
         $this->_availableCommission = user::getAvailableComm($agent_id);
         //            BADGE
         $countAccPaymentBadge = user::countBadge("user_payment", "status = '0'");
         $this->_accPaymentBadge = $countAccPaymentBadge > 0 ? $countAccPaymentBadge : "";
         $countWithdrawalBadge = user::countBadge("user_withdrawal", "status = '0' OR status = '1'");
         $this->_withdrawalBadge = $countWithdrawalBadge > 0 ? $countWithdrawalBadge : "";
         //            $countMessageBadge = user::countBadge("user_messages", "agent_id = '$agent_id' AND status = '0'");
         //            $this->_messageBadge = ($countMessageBadge > 0) ? $countMessageBadge : "";
     }
     $this->view->_userData = $this->_userData;
     $this->view->_userAccType = $this->_userAccType;
     $this->view->_userProfileImages = $this->_userProfileImages;
     $this->view->_availableCommission = $this->_availableCommission;
     //        BADGE
     $this->view->_accPaymentBadge = $this->_accPaymentBadge;
     $this->view->_withdrawalBadge = $this->_withdrawalBadge;
     //        $this->view->_messageBadge = $this->_messageBadge;
 }