Exemplo n.º 1
0
 private function aProfile($pid)
 {
     $this->caller->requireAuthentication();
     require_once FRAMEWORK_PATH . 'models/profile.php';
     if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
         if ($pid == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
             $profile = new Profile($this->registry, $pid);
             if ($profile->isValid()) {
                 $data = $this->caller->getRequestData();
                 $profile->setName($this->registry->getObject('db')->sanitizeData($data['name']));
                 $profile->setDinoName($this->registry->getObject('db')->sanitizeData($data['dino_name']));
                 // etc, set all appropriate methods
                 $profile->save();
                 header('HTTP/1.0 204 No Content');
                 exit;
             } else {
                 header('HTTP/1.0 404 Not Found');
                 exit;
             }
         } else {
             header('HTTP/1.0 403 Forbidden');
             exit;
         }
     } else {
         $profile = new Profile($this->registry, $pid);
         if ($profile->isValid()) {
             header('HTTP/1.0 200 OK');
             echo json_encode($profile->toArray());
             exit;
         } else {
             header('HTTP/1.0 404 Not Found');
             exit;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Migrar los perfiles con formato anterior a v1.2
  *
  * @return bool
  */
 public static function migrateProfiles()
 {
     $query = 'SELECT userprofile_id AS id,' . 'userprofile_name AS name,' . 'BIN(userProfile_pView) AS pView,' . 'BIN(userProfile_pViewPass) AS pViewPass,' . 'BIN(userProfile_pViewHistory) AS pViewHistory,' . 'BIN(userProfile_pEdit) AS pEdit,' . 'BIN(userProfile_pEditPass) AS pEditPass,' . 'BIN(userProfile_pAdd) AS pAdd,' . 'BIN(userProfile_pDelete) AS pDelete,' . 'BIN(userProfile_pFiles) AS pFiles,' . 'BIN(userProfile_pConfig) AS pConfig,' . 'BIN(userProfile_pConfigMasterPass) AS pConfigMasterPass,' . 'BIN(userProfile_pConfigBackup) AS pConfigBackup,' . 'BIN(userProfile_pAppMgmtCategories) AS pAppMgmtCategories,' . 'BIN(userProfile_pAppMgmtCustomers) AS pAppMgmtCustomers,' . 'BIN(userProfile_pUsers) AS pUsers,' . 'BIN(userProfile_pGroups) AS pGroups,' . 'BIN(userProfile_pProfiles) AS pProfiles,' . 'BIN(userProfile_pEventlog) AS pEventlog ' . 'FROM usrProfiles';
     DB::setReturnArray();
     $queryRes = DB::getResults($query, __FUNCTION__);
     if ($queryRes === false) {
         Log::writeNewLog(_('Migrar Perfiles'), _('Error al obtener perfiles'));
         return false;
     }
     foreach ($queryRes as $oldProfile) {
         $profile = new Profile();
         $profile->setId($oldProfile->id);
         $profile->setName($oldProfile->name);
         $profile->setAccAdd($oldProfile->pAdd);
         $profile->setAccView($oldProfile->pView);
         $profile->setAccViewPass($oldProfile->pViewPass);
         $profile->setAccViewHistory($oldProfile->pViewHistory);
         $profile->setAccEdit($oldProfile->pEdit);
         $profile->setAccEditPass($oldProfile->pEditPass);
         $profile->setAccDelete($oldProfile->pDelete);
         $profile->setConfigGeneral($oldProfile->pConfig);
         $profile->setConfigEncryption($oldProfile->pConfigMasterPass);
         $profile->setConfigBackup($oldProfile->pConfigBackup);
         $profile->setMgmCategories($oldProfile->pAppMgmtCategories);
         $profile->setMgmCustomers($oldProfile->pAppMgmtCustomers);
         $profile->setMgmUsers($oldProfile->pUsers);
         $profile->setMgmGroups($oldProfile->pGroups);
         $profile->setMgmProfiles($oldProfile->pProfiles);
         $profile->setEvl($oldProfile->pEventlog);
         if ($profile->profileUpdate() === false) {
             return false;
         }
     }
     $query = 'ALTER TABLE usrProfiles ' . 'DROP COLUMN userProfile_pAppMgmtCustomers,' . 'DROP COLUMN userProfile_pAppMgmtCategories,' . 'DROP COLUMN userProfile_pAppMgmtMenu,' . 'DROP COLUMN userProfile_pUsersMenu,' . 'DROP COLUMN userProfile_pConfigMenu,' . 'DROP COLUMN userProfile_pFiles,' . 'DROP COLUMN userProfile_pViewHistory,' . 'DROP COLUMN userProfile_pEventlog,' . 'DROP COLUMN userProfile_pEditPass,' . 'DROP COLUMN userProfile_pViewPass,' . 'DROP COLUMN userProfile_pDelete,' . 'DROP COLUMN userProfile_pProfiles,' . 'DROP COLUMN userProfile_pGroups,' . 'DROP COLUMN userProfile_pUsers,' . 'DROP COLUMN userProfile_pConfigBackup,' . 'DROP COLUMN userProfile_pConfigMasterPass,' . 'DROP COLUMN userProfile_pConfig,' . 'DROP COLUMN userProfile_pAdd,' . 'DROP COLUMN userProfile_pEdit,' . 'DROP COLUMN userProfile_pView';
     $queryRes = DB::getQuery($query, __FUNCTION__);
     $log = new Log(_('Migrar Perfiles'));
     if ($queryRes) {
         $log->addDescription(_('Operación realizada correctamente'));
     } else {
         $log->addDescription(_('Migrar Perfiles'), _('Fallo al realizar la operación'));
     }
     $log->writeLog();
     Email::sendEmail($log);
     return $queryRes;
 }
 /**
  * Edit your profile
  * @return void
  */
 private function editProfile()
 {
     if ($this->registry->getObject('authenticate')->isLoggedIn() == true) {
         $user = $this->registry->getObject('authenticate')->getUser()->getUserID();
         if (isset($_POST) && count($_POST) > 0) {
             // edit form submitted
             $profile = new Profile($this->registry, $user);
             $profile->setBio($this->registry->getObject('db')->sanitizeData($_POST['bio']));
             $profile->setName($this->registry->getObject('db')->sanitizeData($_POST['name']));
             $profile->setDinoName($this->registry->getObject('db')->sanitizeData($_POST['dino_name']));
             $profile->setDinoBreed($this->registry->getObject('db')->sanitizeData($_POST['dino_breed']));
             $profile->setDinoGender($this->registry->getObject('db')->sanitizeData($_POST['dino_gender']), false);
             $profile->setDinoDOB($this->registry->getObject('db')->sanitizeData($_POST['dino_dob']), false);
             if (isset($_POST['profile_picture'])) {
                 require_once FRAMEWORK_PATH . 'lib/images/imagemanager.class.php';
                 $im = new Imagemanager();
                 $im->loadFromPost('profile_picture', $this->registry->getSetting('uploads_path') . 'profile/', time());
                 if ($im == true) {
                     $im->resizeScaleHeight(150);
                     $im->save($this->registry->getSetting('uploads_path') . 'profile/' . $im->getName());
                     $profile->setPhoto($im->getName());
                 }
             }
             $profile->save();
             $this->registry->redirectUser(array('profile', 'view', 'edit'), 'Profile saved', 'The changes to your profile have been saved', false);
         } else {
             // show the edit form
             $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'profile/information/edit.tpl.php', 'footer.tpl.php');
             // get the profile information to pre-populate the form fields
             require_once FRAMEWORK_PATH . 'models/profile.php';
             $profile = new Profile($this->registry, $user);
             $profile->toTags('p_');
         }
     } else {
         $this->registry->errorPage('Please login', 'You need to be logged in to edit your profile');
     }
 }
Exemplo n.º 4
0
 }
 if (!$listOfCurMembers) {
     $listOfCurMembers = array();
 }
 $listN = array();
 $listC = array();
 foreach ($listOfMembers as $member) {
     $listN[$member['uuid'] . '##' . $member['hostname']] = $member;
 }
 foreach ($listOfCurMembers as $member) {
     $listC[$member['uuid'] . '##' . $member['hostname']] = $member;
 }
 $newmem = array_diff_assoc($listN, $listC);
 $delmem = array_diff_assoc($listC, $listN);
 if ($group->id) {
     $group->setName($name);
     if ($visibility == 'show') {
         $group->show();
     } else {
         $group->hide();
     }
 } else {
     $group->create($name, $visibility == 'show');
     if ($type == 1) {
         $group->setImagingServer($imaging_server);
     }
 }
 $ret_add = $group->addMembers($newmem);
 $res = $group->delMembers($delmem) && $ret_add[0];
 if ($res) {
     if ($already_exists) {
Exemplo n.º 5
0
 /**
  * Crear el usuario admin de sysPass.
  * Esta función crea el grupo, perfil y usuario 'admin' para utilizar sysPass.
  *
  * @throws SPException
  */
 private static function createAdminAccount()
 {
     // Datos del grupo
     Groups::$groupName = "Admins";
     Groups::$groupDescription = "Admins";
     if (!Groups::addGroup()) {
         self::rollback();
         throw new SPException(SPException::SP_CRITICAL, _('Error al crear el grupo "admin"'), _('Informe al desarrollador'));
     }
     $User = new User();
     // Establecer el id de grupo del usuario al recién creado
     $User->setUserGroupId(Groups::$queryLastId);
     $Profile = new Profile();
     $Profile->setName('Admin');
     $Profile->setAccAdd(true);
     $Profile->setAccView(true);
     $Profile->setAccViewPass(true);
     $Profile->setAccViewHistory(true);
     $Profile->setAccEdit(true);
     $Profile->setAccEditPass(true);
     $Profile->setAccDelete(true);
     $Profile->setConfigGeneral(true);
     $Profile->setConfigEncryption(true);
     $Profile->setConfigBackup(true);
     $Profile->setMgmCategories(true);
     $Profile->setMgmCustomers(true);
     $Profile->setMgmUsers(true);
     $Profile->setMgmGroups(true);
     $Profile->setMgmProfiles(true);
     $Profile->setEvl(true);
     if (!$Profile->profileAdd()) {
         self::rollback();
         throw new SPException(SPException::SP_CRITICAL, _('Error al crear el perfil "admin"'), _('Informe al desarrollador'));
     }
     // Datos del usuario
     $User->setUserLogin(self::$_username);
     $User->setUserPass(self::$_password);
     $User->setUserName('Admin');
     $User->setUserProfileId($Profile->getId());
     $User->setUserIsAdminApp(true);
     $User->setUserIsAdminAcc(false);
     $User->setUserIsDisabled(false);
     if (!$User->addUser()) {
         self::rollback();
         throw new SPException(SPException::SP_CRITICAL, _('Error al crear el usuario "admin"'), _('Informe al desarrollador'));
     }
     // Guardar el hash de la clave maestra
     ConfigDB::setCacheConfigValue('masterPwd', Crypt::mkHashPassword(self::$_masterPassword));
     ConfigDB::setCacheConfigValue('lastupdatempass', time());
     ConfigDB::writeConfig(true);
     if (!$User->updateUserMPass(self::$_masterPassword)) {
         self::rollback();
         throw new SPException(SPException::SP_CRITICAL, _('Error al actualizar la clave maestra del usuario "admin"'), _('Informe al desarrollador'));
     }
 }