Example #1
0
 function process(Vtiger_Request $request)
 {
     $username = $request->get('username');
     $password = $request->get('password');
     $user = CRMEntity::getInstance('Users');
     $user->column_fields['user_name'] = $username;
     if ($user->doLogin($password)) {
         $userid = $user->retrieve_user_id($username);
         Vtiger_Session::set('AUTHUSERID', $userid);
         // For Backward compatability
         // TODO Remove when switch-to-old look is not needed
         $_SESSION['authenticated_user_id'] = $userid;
         $_SESSION['app_unique_key'] = vglobal('application_unique_key');
         $_SESSION['authenticated_user_language'] = vglobal('default_language');
         //Enabled session variable for KCFINDER
         $_SESSION['KCFINDER'] = array();
         $_SESSION['KCFINDER']['disabled'] = false;
         $_SESSION['KCFINDER']['uploadURL'] = "test/upload";
         $_SESSION['KCFINDER']['uploadDir'] = "test/upload";
         $deniedExts = implode(" ", vglobal('upload_badext'));
         $_SESSION['KCFINDER']['deniedExts'] = $deniedExts;
         // End
         //Track the login History
         $moduleModel = Users_Module_Model::getInstance('Users');
         $moduleModel->saveLoginHistory($user->column_fields['user_name']);
         //End
         header('Location: index.php?module=Users&parent=Settings&view=SystemSetup');
         exit;
     } else {
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=1');
         exit;
     }
 }
Example #2
0
 function process(Vtiger_Request $request)
 {
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $baseUserId = $currentUserModel->getId();
     $userId = $request->get('id');
     $user = new Users();
     $currentUser = $user->retrieveCurrentUserInfoFromFile($userId);
     $name = $currentUserModel->getName();
     $userName = $currentUser->column_fields['user_name'];
     Vtiger_Session::set('AUTHUSERID', $userId);
     Vtiger_Session::set('authenticated_user_id', $userId);
     Vtiger_Session::set('user_name', $userName);
     Vtiger_Session::set('full_user_name', $name);
     $status = 'Switched';
     if (Vtiger_Session::get('baseUserId') == '') {
         Vtiger_Session::set('baseUserId', $baseUserId);
         $status = 'Signed in';
     } elseif ($userId == Vtiger_Session::get('baseUserId')) {
         $baseUserId = $userId;
         Vtiger_Session::set('baseUserId', '');
         $status = 'Signed out';
     } else {
         $baseUserId = Vtiger_Session::get('baseUserId');
     }
     $dbLog = PearDatabase::getInstance('log');
     $dbLog->insert('l_yf_switch_users', ['baseid' => $baseUserId, 'destid' => $userId, 'busername' => $currentUserModel->getName(), 'dusername' => $name, 'date' => date('Y-m-d H:i:s'), 'ip' => Vtiger_Functions::getRemoteIP(), 'agent' => $_SERVER['HTTP_USER_AGENT'], 'status' => $status]);
     header('Location: index.php');
 }
Example #3
0
 function process(Vtiger_Request $request)
 {
     $username = $request->get('username');
     $password = $request->get('password');
     if ($request->get('mode') == 'install') {
         error_reporting(0);
         $dirPath = 'install';
         foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
             $path->isDir() ? rmdir($path->getPathname()) : unlink($path->getPathname());
         }
         rmdir($dirPath);
     }
     $checkBlocked = Settings_BruteForce_Module_Model::checkBlocked();
     $bruteForceSettings = Settings_BruteForce_Module_Model::getBruteForceSettings();
     if ($checkBlocked && $bruteForceSettings['active']) {
         Settings_BruteForce_Module_Model::sendNotificationEmail();
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=2');
         exit;
     }
     $user = CRMEntity::getInstance('Users');
     $user->column_fields['user_name'] = $username;
     $moduleModel = Users_Module_Model::getInstance('Users');
     if ($user->doLogin($password)) {
         if (vglobal('session_regenerate_id')) {
             session_regenerate_id(true);
         }
         // to overcome session id reuse.
         $userid = $user->retrieve_user_id($username);
         Vtiger_Session::set('AUTHUSERID', $userid);
         // For Backward compatability
         // TODO Remove when switch-to-old look is not needed
         $_SESSION['authenticated_user_id'] = $userid;
         $_SESSION['app_unique_key'] = vglobal('application_unique_key');
         $_SESSION['authenticated_user_language'] = vglobal('default_language');
         $_SESSION['user_name'] = $username;
         $_SESSION['full_user_name'] = Vtiger_Functions::getUserRecordLabel($userid);
         //Enabled session variable for KCFINDER
         $_SESSION['KCFINDER'] = array();
         $_SESSION['KCFINDER']['disabled'] = false;
         $_SESSION['KCFINDER']['uploadURL'] = "cache/upload";
         $_SESSION['KCFINDER']['uploadDir'] = "../../cache/upload";
         $deniedExts = implode(" ", vglobal('upload_badext'));
         $_SESSION['KCFINDER']['deniedExts'] = $deniedExts;
         // End
         //Track the login History
         $moduleModel->saveLoginHistory($user->column_fields['user_name']);
         //End
         header('Location: index.php');
         exit;
     } else {
         //Track the login History
         $browser = Settings_BruteForce_Module_Model::browserDetect();
         $moduleModel->saveLoginHistory($username, 'Failed login', $browser);
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=1');
         exit;
     }
 }
Example #4
0
 /**
  * Function to check if the User has logged in
  * @param Vtiger_Request $request
  * @throws AppException
  */
 protected function checkLogin(Vtiger_Request $request)
 {
     if (!$this->hasLogin()) {
         $return_params = $_SERVER['QUERY_STRING'];
         if ($return_params && !$_SESSION['return_params']) {
             //Take the url that user would like to redirect after they have successfully logged in.
             $return_params = urlencode($return_params);
             Vtiger_Session::set('return_params', $return_params);
         }
         header('Location: index.php');
         throw new NoPermittedException('Login is required');
     }
 }
Example #5
0
 function process(Vtiger_Request $request)
 {
     $username = $request->get('username');
     $password = $request->get('password');
     if ($request->get('mode') == 'install') {
         $dirPath = 'install';
         Users_Module_Model::deleteLangFiles();
         $configTemplate = "config/config.template.php";
         if (file_exists($configTemplate)) {
             unlink($configTemplate);
         }
         Vtiger_Functions::recurseDelete($dirPath);
     }
     $checkBlocked = Settings_BruteForce_Module_Model::checkBlocked();
     $bruteForceSettings = Settings_BruteForce_Module_Model::getBruteForceSettings();
     if ($checkBlocked && $bruteForceSettings['active']) {
         Settings_BruteForce_Module_Model::sendNotificationEmail();
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=2');
         exit;
     }
     $user = CRMEntity::getInstance('Users');
     $user->column_fields['user_name'] = $username;
     $moduleModel = Users_Module_Model::getInstance('Users');
     if ($user->doLogin($password)) {
         if (vglobal('session_regenerate_id')) {
             Vtiger_Session::regenerateId(true);
         }
         // to overcome session id reuse.
         $userid = $user->retrieve_user_id($username);
         Vtiger_Session::set('AUTHUSERID', $userid);
         // For Backward compatability
         // TODO Remove when switch-to-old look is not needed
         Vtiger_Session::set('authenticated_user_id', $userid);
         Vtiger_Session::set('app_unique_key', vglobal('application_unique_key'));
         Vtiger_Session::set('authenticated_user_language', vglobal('default_language'));
         Vtiger_Session::set('user_name', $username);
         Vtiger_Session::set('full_user_name', Vtiger_Functions::getUserRecordLabel($userid));
         if ($request->has('language') && vglobal('langInLoginView')) {
             Vtiger_Session::set('language', $request->get('language'));
         }
         if ($request->has('layout')) {
             Vtiger_Session::set('layout', $request->get('layout'));
         }
         //Enabled session variable for KCFINDER
         $_SESSION['KCFINDER'] = array();
         $_SESSION['KCFINDER']['disabled'] = false;
         $_SESSION['KCFINDER']['uploadURL'] = "cache/upload";
         $_SESSION['KCFINDER']['uploadDir'] = "../../cache/upload";
         $deniedExts = implode(" ", vglobal('upload_badext'));
         $_SESSION['KCFINDER']['deniedExts'] = $deniedExts;
         // End
         //Track the login History
         $moduleModel->saveLoginHistory($user->column_fields['user_name']);
         //End
         if (isset($_SESSION['return_params'])) {
             $return_params = urldecode($_SESSION['return_params']);
             header("Location: index.php?{$return_params}");
             exit;
         } else {
             header('Location: index.php');
             exit;
         }
     } else {
         //Track the login History
         $browser = Settings_BruteForce_Module_Model::browserDetect();
         $moduleModel->saveLoginHistory($username, 'Failed login', $browser);
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=1');
         exit;
     }
 }
 public static function setSessionQuery($currentModule, $query, $viewid)
 {
     if (Vtiger_Session::has($currentModule . '_listquery')) {
         if (Vtiger_Session::get($currentModule . '_listquery') != $query) {
             Vtiger_Session::remove($currentModule . '_DetailView_Navigation' . $viewid);
         }
     }
     Vtiger_Session::set($currentModule . '_listquery', $query);
 }