* [MOD] Improved parsing request data

This commit is contained in:
nuxsmin
2018-03-03 12:44:02 +01:00
parent 7ec589a6fe
commit e0a45f4b2e
56 changed files with 436 additions and 437 deletions

View File

@@ -104,7 +104,7 @@ class AccessManagerController extends ControllerBase
$this->eventDispatcher->notifyEvent('show.itemlist.accesses', new Event($this));
$this->tabsGridHelper->renderTabs(Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE), Request::analyze('tabIndex', 0));
$this->tabsGridHelper->renderTabs(Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE), Request::analyzeInt('tabIndex', 0));
$this->view();
}

View File

@@ -34,7 +34,6 @@ use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\AccountExtData;
use SP\Forms\AccountForm;
use SP\Http\JsonResponse;
use SP\Modules\Web\Controllers\Helpers\Account\AccountHelper;
use SP\Modules\Web\Controllers\Helpers\Account\AccountHistoryHelper;
@@ -43,6 +42,7 @@ use SP\Modules\Web\Controllers\Helpers\Account\AccountSearchHelper;
use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\AccountForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Services\Account\AccountHistoryService;
use SP\Services\Account\AccountService;

View File

@@ -228,7 +228,7 @@ class AccountFileController extends ControllerBase implements CrudControllerInte
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
@@ -334,8 +334,8 @@ class AccountFileController extends ControllerBase implements CrudControllerInte
try {
$this->view->addTemplate('files-list', 'account');
$this->view->assign('deleteEnabled', Request::analyze('del', 0));
$this->view->assign('files', (new AccountFileService())->getByAccountId($accountId));
$this->view->assign('deleteEnabled', Request::analyzeBool('del', false));
$this->view->assign('files', $this->dic->get(AccountFileService::class)->getByAccountId($accountId));
$this->view->assign('sk', $this->session->getSecurityKey());
$this->view->assign('fileViewRoute', Acl::getActionRoute(ActionsInterface::ACCOUNT_FILE_VIEW));
$this->view->assign('fileDownloadRoute', Acl::getActionRoute(ActionsInterface::ACCOUNT_FILE_DOWNLOAD));

View File

@@ -30,13 +30,13 @@ use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\AuthTokenData;
use SP\Forms\AuthTokenForm;
use SP\Http\JsonResponse;
use SP\Http\Request;
use SP\Mgmt\ApiTokens\ApiTokensUtil;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\AuthTokenForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Mvc\View\Components\SelectItemAdapter;
use SP\Services\AuthToken\AuthTokenService;
@@ -71,7 +71,7 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);

View File

@@ -30,12 +30,12 @@ use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\CategoryData;
use SP\Forms\CategoryForm;
use SP\Http\JsonResponse;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\CategoryForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Services\Category\CategoryService;
@@ -68,7 +68,7 @@ class CategoryController extends ControllerBase implements CrudControllerInterfa
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);

View File

@@ -31,12 +31,12 @@ use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\ClientData;
use SP\Forms\ClientForm;
use SP\Http\JsonResponse;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\ClientForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Services\Client\ClientService;
@@ -69,7 +69,7 @@ class ClientController extends ControllerBase implements CrudControllerInterface
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);

View File

@@ -24,6 +24,7 @@
namespace SP\Modules\Web\Controllers;
use SP\Config\ConfigUtil;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Acl\UnauthorizedPageException;
use SP\Core\Events\Event;
@@ -51,12 +52,12 @@ class ConfigAccountController extends SimpleControllerBase
$eventMessage = EventMessage::factory();
// Accounts
$globalSearchEnabled = Request::analyze('globalsearch', false, false, true);
$accountPassToImageEnabled = Request::analyze('account_passtoimage', false, false, true);
$accountLinkEnabled = Request::analyze('account_link', false, false, true);
$accountFullGroupAccessEnabled = Request::analyze('account_fullgroup_access', false, false, true);
$accountCount = Request::analyze('account_count', 10);
$resultsAsCardsEnabled = Request::analyze('resultsascards', false, false, true);
$globalSearchEnabled = Request::analyzeBool('globalsearch', false);
$accountPassToImageEnabled = Request::analyzeBool('account_passtoimage', false);
$accountLinkEnabled = Request::analyzeBool('account_link', false);
$accountFullGroupAccessEnabled = Request::analyzeBool('account_fullgroup_access', false);
$accountCount = Request::analyzeInt('account_count', 10);
$resultsAsCardsEnabled = Request::analyzeBool('resultsascards', false);
$configData->setGlobalSearch($globalSearchEnabled);
$configData->setAccountPassToImage($accountPassToImageEnabled);
@@ -66,9 +67,9 @@ class ConfigAccountController extends SimpleControllerBase
$configData->setResultsAsCards($resultsAsCardsEnabled);
// Files
$filesEnabled = Request::analyze('files_enabled', false, false, true);
$filesAllowedSize = Request::analyze('files_allowed_size', 1024);
$filesAllowedExts = Request::analyze('files_allowed_exts');
$filesEnabled = Request::analyzeBool('files_enabled', false);
$filesAllowedSize = Request::analyzeInt('files_allowed_size', 1024);
$filesAllowedExts = ConfigUtil::filesExtsAdapter(Request::analyzeString('files_allowed_exts'));
if ($filesEnabled) {
if ($filesAllowedSize >= 16384) {
@@ -85,10 +86,10 @@ class ConfigAccountController extends SimpleControllerBase
$configData->setFilesAllowedSize($filesAllowedSize);
// Public Links
$pubLinksEnabled = Request::analyze('publinks_enabled', false, false, true);
$pubLinksImageEnabled = Request::analyze('publinks_image_enabled', false, false, true);
$pubLinksMaxTime = Request::analyze('publinks_maxtime', 10);
$pubLinksMaxViews = Request::analyze('publinks_maxviews', 3);
$pubLinksEnabled = Request::analyzeBool('publinks_enabled', false);
$pubLinksImageEnabled = Request::analyzeBool('publinks_image_enabled', false);
$pubLinksMaxTime = Request::analyzeInt('publinks_maxtime', 10);
$pubLinksMaxViews = Request::analyzeInt('publinks_maxviews', 3);
$configData->setPublinksEnabled($pubLinksEnabled);
$configData->setPublinksImageEnabled($pubLinksImageEnabled);

View File

@@ -64,8 +64,8 @@ class ConfigEncryptionController extends SimpleControllerBase
$currentMasterPass = Request::analyzeEncrypted('curMasterPwd');
$newMasterPass = Request::analyzeEncrypted('newMasterPwd');
$newMasterPassR = Request::analyzeEncrypted('newMasterPwdR');
$confirmPassChange = Request::analyze('confirmPassChange', 0, false, 1);
$noAccountPassChange = Request::analyze('chkNoAccountChange', 0, false, 1);
$confirmPassChange = Request::analyzeBool('confirmPassChange', false);
$noAccountPassChange = Request::analyzeBool('chkNoAccountChange', false);
if (!$mastePassService->checkUserUpdateMPass($this->session->getUserData()->getLastUpdateMPass())) {
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS_STICKY, __u('Clave maestra actualizada'), [__u('Reinicie la sesión para cambiarla')]);
@@ -165,7 +165,7 @@ class ConfigEncryptionController extends SimpleControllerBase
{
try {
$temporaryMasterPassService = $this->dic->get(TemporaryMasterPassService::class);
$temporaryMasterPassService->create(Request::analyze('tmpass_maxtime', 3600));
$temporaryMasterPassService->create(Request::analyzeInt('tmpass_maxtime', 3600));
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Clave Temporal Generada'));
} catch (ServiceException $e) {

View File

@@ -50,15 +50,15 @@ class ConfigGeneralController extends SimpleControllerBase
$eventMessage = EventMessage::factory();
// General
$siteLang = Request::analyze('sitelang');
$siteTheme = Request::analyze('sitetheme', 'material-blue');
$sessionTimeout = Request::analyze('session_timeout', 300);
$httpsEnabled = Request::analyze('https_enabled', false, false, true);
$debugEnabled = Request::analyze('debug', false, false, true);
$maintenanceEnabled = Request::analyze('maintenance', false, false, true);
$checkUpdatesEnabled = Request::analyze('updates', false, false, true);
$checkNoticesEnabled = Request::analyze('notices', false, false, true);
$encryptSessionEnabled = Request::analyze('encryptsession', false, false, true);
$siteLang = Request::analyzeString('sitelang');
$siteTheme = Request::analyzeString('sitetheme', 'material-blue');
$sessionTimeout = Request::analyzeInt('session_timeout', 300);
$httpsEnabled = Request::analyzeBool('https_enabled', false);
$debugEnabled = Request::analyzeBool('debug', false);
$maintenanceEnabled = Request::analyzeBool('maintenance', false);
$checkUpdatesEnabled = Request::analyzeBool('updates', false);
$checkNoticesEnabled = Request::analyzeBool('notices', false);
$encryptSessionEnabled = Request::analyzeBool('encryptsession', false);
$configData->setSiteLang($siteLang);
$configData->setSiteTheme($siteTheme);
@@ -71,11 +71,11 @@ class ConfigGeneralController extends SimpleControllerBase
$configData->setEncryptSession($encryptSessionEnabled);
// Events
$logEnabled = Request::analyze('log_enabled', false, false, true);
$syslogEnabled = Request::analyze('syslog_enabled', false, false, true);
$remoteSyslogEnabled = Request::analyze('remotesyslog_enabled', false, false, true);
$syslogServer = Request::analyze('remotesyslog_server');
$syslogPort = Request::analyze('remotesyslog_port', 0);
$logEnabled = Request::analyzeBool('log_enabled', false);
$syslogEnabled = Request::analyzeBool('syslog_enabled', false);
$remoteSyslogEnabled = Request::analyzeBool('remotesyslog_enabled', false);
$syslogServer = Request::analyzeString('remotesyslog_server');
$syslogPort = Request::analyzeInt('remotesyslog_port', 0);
$configData->setLogEnabled($logEnabled);
$configData->setSyslogEnabled($syslogEnabled);
@@ -99,10 +99,10 @@ class ConfigGeneralController extends SimpleControllerBase
}
// Proxy
$proxyEnabled = Request::analyze('proxy_enabled', false, false, true);
$proxyServer = Request::analyze('proxy_server');
$proxyPort = Request::analyze('proxy_port', 0);
$proxyUser = Request::analyze('proxy_user');
$proxyEnabled = Request::analyzeBool('proxy_enabled', false);
$proxyServer = Request::analyzeString('proxy_server');
$proxyPort = Request::analyzeInt('proxy_port', 8080);
$proxyUser = Request::analyzeString('proxy_user');
$proxyPass = Request::analyzeEncrypted('proxy_pass');
@@ -128,11 +128,11 @@ class ConfigGeneralController extends SimpleControllerBase
}
// Autentificación
$authBasicEnabled = Request::analyze('authbasic_enabled', false, false, true);
$authBasicAutologinEnabled = Request::analyze('authbasicautologin_enabled', false, false, true);
$authBasicDomain = Request::analyze('authbasic_domain');
$authSsoDefaultGroup = Request::analyze('sso_defaultgroup', false, false, true);
$authSsoDefaultProfile = Request::analyze('sso_defaultprofile', false, false, true);
$authBasicEnabled = Request::analyzeBool('authbasic_enabled', false);
$authBasicAutologinEnabled = Request::analyzeBool('authbasicautologin_enabled', false);
$authBasicDomain = Request::analyzeString('authbasic_domain');
$authSsoDefaultGroup = Request::analyzeInt('sso_defaultgroup');
$authSsoDefaultProfile = Request::analyzeInt('sso_defaultprofile');
// Valores para Autentificación
if ($authBasicEnabled) {

View File

@@ -57,11 +57,11 @@ class ConfigImportController extends SimpleControllerBase
}
$importParams = new ImportParams();
$importParams->setDefaultUser(Request::analyze('import_defaultuser', $this->session->getUserData()->getId()));
$importParams->setDefaultGroup(Request::analyze('import_defaultgroup', $this->session->getUserData()->getUserGroupId()));
$importParams->setDefaultUser(Request::analyzeInt('import_defaultuser', $this->session->getUserData()->getId()));
$importParams->setDefaultGroup(Request::analyzeInt('import_defaultgroup', $this->session->getUserData()->getUserGroupId()));
$importParams->setImportPwd(Request::analyzeEncrypted('importPwd'));
$importParams->setImportMasterPwd(Request::analyzeEncrypted('importMasterPwd'));
$importParams->setCsvDelimiter(Request::analyze('csvDelimiter'));
$importParams->setCsvDelimiter(Request::analyzeString('csvDelimiter'));
try {
$importService = $this->dic->get(ImportService::class);

View File

@@ -38,7 +38,6 @@ use SP\Providers\Auth\Ldap\LdapParams;
use SP\Services\Ldap\LdapCheckService;
use SP\Services\Ldap\LdapImportParams;
use SP\Services\Ldap\LdapImportService;
use SP\Util\Util;
/**
* Class ConfigLdapController
@@ -59,9 +58,9 @@ class ConfigLdapController extends SimpleControllerBase
$configData = $this->config->getConfigData();
// LDAP
$ldapEnabled = Request::analyze('ldap_enabled', false, false, true);
$ldapDefaultGroup = Request::analyze('ldap_defaultgroup', 0);
$ldapDefaultProfile = Request::analyze('ldap_defaultprofile', 0);
$ldapEnabled = Request::analyzeBool('ldap_enabled', false);
$ldapDefaultGroup = Request::analyzeInt('ldap_defaultgroup');
$ldapDefaultProfile = Request::analyzeInt('ldap_defaultprofile');
$ldapParams = $this->getLdapParamsFromRequest();
@@ -104,7 +103,7 @@ class ConfigLdapController extends SimpleControllerBase
*/
protected function getLdapParamsFromRequest()
{
$data = LdapParams::getServerAndPort(Request::analyze('ldap_server'));
$data = LdapParams::getServerAndPort(Request::analyzeString('ldap_server'));
if ($data === false) {
throw new ValidationException(__u('Parámetros de LDAP incorrectos'));
@@ -113,11 +112,11 @@ class ConfigLdapController extends SimpleControllerBase
return (new LdapParams())
->setServer($data['server'])
->setPort(isset($data['port']) ? $data['port'] : 389)
->setSearchBase(Request::analyze('ldap_base'))
->setGroup(Request::analyze('ldap_group'))
->setBindDn(Request::analyze('ldap_binduser'))
->setSearchBase(Request::analyzeString('ldap_base'))
->setGroup(Request::analyzeString('ldap_group'))
->setBindDn(Request::analyzeString('ldap_binduser'))
->setBindPass(Request::analyzeEncrypted('ldap_bindpass'))
->setAds(Request::analyze('ldap_ads', false, false, true));
->setAds(Request::analyzeBool('ldap_ads', false));
}
/**
@@ -172,10 +171,10 @@ class ConfigLdapController extends SimpleControllerBase
$ldapCheckService = $this->dic->get(LdapCheckService::class);
$ldapCheckService->checkConnection($ldapParams);
$filter = Request::analyze('ldap_import_filter');
$filter = Request::analyzeString('ldap_import_filter');
if (empty($filter)) {
$data = $ldapCheckService->getObjects(Util::boolval(Request::analyze('ldap_import_groups')));
$data = $ldapCheckService->getObjects(Request::analyzeBool('ldap_import_groups', false));
} else {
$data = $ldapCheckService->getObjectsByFilter($filter);
}
@@ -210,14 +209,14 @@ class ConfigLdapController extends SimpleControllerBase
try {
$ldapImportParams = new LdapImportParams();
$ldapImportParams->filter = Request::analyze('ldap_import_filter');
$ldapImportParams->loginAttribute = Request::analyze('ldap_login_attribute');
$ldapImportParams->userNameAttribute = Request::analyze('ldap_username_attribute');
$ldapImportParams->userGroupNameAttribute = Request::analyze('ldap_groupname_attribute');
$ldapImportParams->defaultUserGroup = Request::analyze('ldap_defaultgroup', 0);
$ldapImportParams->defaultUserProfile = Request::analyze('ldap_defaultprofile', 0);
$ldapImportParams->filter = Request::analyzeString('ldap_import_filter');
$ldapImportParams->loginAttribute = Request::analyzeString('ldap_login_attribute');
$ldapImportParams->userNameAttribute = Request::analyzeString('ldap_username_attribute');
$ldapImportParams->userGroupNameAttribute = Request::analyzeString('ldap_groupname_attribute');
$ldapImportParams->defaultUserGroup = Request::analyzeInt('ldap_defaultgroup');
$ldapImportParams->defaultUserProfile = Request::analyzeInt('ldap_defaultprofile');
$checkImportGroups = Util::boolval(Request::analyze('ldap_import_groups'));
$checkImportGroups = Request::analyzeBool('ldap_import_groups', false);
if ((empty($ldapImportParams->loginAttribute)
|| empty($ldapImportParams->userNameAttribute)
@@ -238,7 +237,7 @@ class ConfigLdapController extends SimpleControllerBase
$userLdapService->importUsers($ldapParams, $ldapImportParams);
$filter = Request::analyze('ldap_import_filter');
$filter = Request::analyzeString('ldap_import_filter');
// Groups won't be imported if filter is set
if ($checkImportGroups === true && empty($filter)) {

View File

@@ -50,15 +50,15 @@ class ConfigMailController extends SimpleControllerBase
$configData = $this->config->getConfigData();
// Mail
$mailEnabled = Request::analyze('mail_enabled', false, false, true);
$mailServer = Request::analyze('mail_server');
$mailPort = Request::analyze('mail_port', 25);
$mailUser = Request::analyze('mail_user');
$mailEnabled = Request::analyzeBool('mail_enabled', false);
$mailServer = Request::analyzeString('mail_server');
$mailPort = Request::analyzeInt('mail_port', 25);
$mailUser = Request::analyzeString('mail_user');
$mailPass = Request::analyzeEncrypted('mail_pass');
$mailSecurity = Request::analyze('mail_security');
$mailFrom = Request::analyze('mail_from');
$mailRequests = Request::analyze('mail_requestsenabled', false, false, true);
$mailAuth = Request::analyze('mail_authenabled', false, false, true);
$mailSecurity = Request::analyzeString('mail_security');
$mailFrom = Request::analyzeEmail('mail_from');
$mailRequests = Request::analyzeBool('mail_requestsenabled', false);
$mailAuth = Request::analyzeBool('mail_authenabled', false);
// Valores para la configuración del Correo
if ($mailEnabled && (!$mailServer || !$mailFrom)) {

View File

@@ -121,7 +121,7 @@ class ConfigManagerController extends ControllerBase
$this->eventDispatcher->notifyEvent('show.config', new Event($this));
$this->tabsHelper->renderTabs(Acl::getActionRoute(ActionsInterface::CONFIG), Request::analyze('tabIndex', 0));
$this->tabsHelper->renderTabs(Acl::getActionRoute(ActionsInterface::CONFIG), Request::analyzeInt('tabIndex', 0));
$this->view();
}

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -50,10 +50,10 @@ class ConfigWikiController extends SimpleControllerBase
$configData = $this->config->getConfigData();
// Wiki
$wikiEnabled = Request::analyze('wiki_enabled', false, false, true);
$wikiSearchUrl = Request::analyze('wiki_searchurl');
$wikiPageUrl = Request::analyze('wiki_pageurl');
$wikiFilter = Request::analyze('wiki_filter');
$wikiEnabled = Request::analyzeBool('wiki_enabled', false);
$wikiSearchUrl = Request::analyzeString('wiki_searchurl');
$wikiPageUrl = Request::analyzeString('wiki_pageurl');
$wikiFilter = Request::analyzeString('wiki_filter');
// Valores para la conexión a la Wiki
if ($wikiEnabled && (!$wikiSearchUrl || !$wikiPageUrl || !$wikiFilter)) {
@@ -76,12 +76,12 @@ class ConfigWikiController extends SimpleControllerBase
}
// DokuWiki
$dokuWikiEnabled = Request::analyze('dokuwiki_enabled', false, false, true);
$dokuWikiUrl = Request::analyze('dokuwiki_url');
$dokuWikiUrlBase = Request::analyze('dokuwiki_urlbase');
$dokuWikiUser = Request::analyze('dokuwiki_user');
$dokuWikiEnabled = Request::analyzeBool('dokuwiki_enabled', false);
$dokuWikiUrl = Request::analyzeString('dokuwiki_url');
$dokuWikiUrlBase = Request::analyzeString('dokuwiki_urlbase');
$dokuWikiUser = Request::analyzeString('dokuwiki_user');
$dokuWikiPass = Request::analyzeEncrypted('dokuwiki_pass');
$dokuWikiNamespace = Request::analyze('dokuwiki_namespace');
$dokuWikiNamespace = Request::analyzeString('dokuwiki_namespace');
// Valores para la conexión a la API de DokuWiki
if ($dokuWikiEnabled && (!$dokuWikiUrl || !$dokuWikiUrlBase)) {

View File

@@ -153,10 +153,13 @@ abstract class ControllerBase
$this->view->setBase(strtolower($this->controllerName));
$this->icons = $this->theme->getIcons();
$this->userData = clone $this->session->getUserData();
$this->userProfileData = clone $this->session->getUserProfile();
$this->setViewVars();
if ($this->session->isLoggedIn()) {
$this->userData = clone $this->session->getUserData();
$this->userProfileData = clone $this->session->getUserProfile();
$this->setViewVars();
}
if (method_exists($this, 'initialize')) {
$this->initialize();

View File

@@ -31,12 +31,12 @@ use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\CustomFieldDefinitionData;
use SP\Forms\CustomFieldDefForm;
use SP\Http\JsonResponse;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\CustomFieldDefForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Repositories\CustomField\CustomFieldDefRepository;
use SP\Repositories\CustomField\CustomFieldTypeRepository;
@@ -71,7 +71,7 @@ class CustomFieldController extends ControllerBase implements CrudControllerInte
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);

View File

@@ -30,12 +30,12 @@ use SP\Core\Acl\Acl;
use SP\Core\Exceptions\SPException;
use SP\DataModel\AccountHistoryData;
use SP\DataModel\Dto\AccountAclDto;
use SP\Mgmt\Users\UserPass;
use SP\Modules\Web\Controllers\Helpers\HelperBase;
use SP\Mvc\View\Components\SelectItemAdapter;
use SP\Services\Account\AccountHistoryService;
use SP\Services\Category\CategoryService;
use SP\Services\Client\ClientService;
use SP\Services\Crypt\MasterPassService;
use SP\Util\ErrorUtil;
/**
@@ -111,6 +111,7 @@ class AccountHistoryHelper extends HelperBase
/**
* @return bool
* @throws \SP\Services\Config\ParameterNotFoundException
*/
protected function checkActionAccess()
{
@@ -120,7 +121,7 @@ class AccountHistoryHelper extends HelperBase
return false;
}
if (!UserPass::checkUserUpdateMPass($this->session->getUserData()->getId())) {
if (!$this->dic->get(MasterPassService::class)->checkUserUpdateMPass($this->session->getUserData()->getLastUpdateMPass())) {
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_UPDATE_MPASS);
return false;

View File

@@ -294,7 +294,7 @@ class AccountSearchHelper extends HelperBase
{
$accountSearchFilter = $this->session->getSearchFilters();
if ($accountSearchFilter !== null && empty(Request::analyze('sk'))) {
if ($accountSearchFilter !== null && empty(Request::analyzeString('sk'))) {
// Obtener el filtro de búsqueda desde la sesión
return $accountSearchFilter;
}
@@ -303,16 +303,16 @@ class AccountSearchHelper extends HelperBase
$limitCount = ($userPreferences->getResultsPerPage() > 0) ? $userPreferences->getResultsPerPage() : $this->configData->getAccountCount();
$accountSearchFilter = new AccountSearchFilter();
$accountSearchFilter->setSortKey(Request::analyze('skey', 0));
$accountSearchFilter->setSortOrder(Request::analyze('sorder', 0));
$accountSearchFilter->setLimitStart(Request::analyze('start', 0));
$accountSearchFilter->setLimitCount(Request::analyze('rpp', $limitCount));
$accountSearchFilter->setGlobalSearch(Request::analyze('gsearch', false));
$accountSearchFilter->setClientId(Request::analyze('customer', 0));
$accountSearchFilter->setCategoryId(Request::analyze('category', 0));
$accountSearchFilter->setTagsId(Request::analyze('tags'));
$accountSearchFilter->setSearchFavorites(Request::analyze('searchfav', false));
$accountSearchFilter->setTxtSearch(Request::analyze('search'));
$accountSearchFilter->setSortKey(Request::analyzeInt('skey', 0));
$accountSearchFilter->setSortOrder(Request::analyzeInt('sorder', 0));
$accountSearchFilter->setLimitStart(Request::analyzeInt('start', 0));
$accountSearchFilter->setLimitCount(Request::analyzeInt('rpp', $limitCount));
$accountSearchFilter->setGlobalSearch(Request::analyzeBool('gsearch', false));
$accountSearchFilter->setClientId(Request::analyzeInt('client'));
$accountSearchFilter->setCategoryId(Request::analyzeInt('category'));
$accountSearchFilter->setTagsId(Request::analyzeArray('tags'));
$accountSearchFilter->setSearchFavorites(Request::analyzeBool('searchfav', false));
$accountSearchFilter->setTxtSearch(Request::analyzeString('search'));
$accountSearchFilter->setSortViews($userPreferences->isSortViews());
return $accountSearchFilter;

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -107,15 +107,15 @@ class InstallController extends ControllerBase
public function installAction()
{
$installData = new InstallData();
$installData->setSiteLang(Request::analyze('sitelang', 'en_US'));
$installData->setAdminLogin(Request::analyze('adminlogin', 'admin'));
$installData->setSiteLang(Request::analyzeString('sitelang', 'en_US'));
$installData->setAdminLogin(Request::analyzeString('adminlogin', 'admin'));
$installData->setAdminPass(Request::analyzeEncrypted('adminpass'));
$installData->setMasterPassword(Request::analyzeEncrypted('masterpassword'));
$installData->setDbAdminUser(Request::analyze('dbuser', 'root'));
$installData->setDbAdminUser(Request::analyzeString('dbuser', 'root'));
$installData->setDbAdminPass(Request::analyzeEncrypted('dbpass'));
$installData->setDbName(Request::analyze('dbname', 'syspass'));
$installData->setDbHost(Request::analyze('dbhost', 'localhost'));
$installData->setHostingMode(Request::analyze('hostingmode', false));
$installData->setDbName(Request::analyzeString('dbname', 'syspass'));
$installData->setDbHost(Request::analyzeString('dbhost', 'localhost'));
$installData->setHostingMode(Request::analyzeBool('hostingmode', false));
try {
Installer::run($installData);

View File

@@ -119,7 +119,7 @@ class ItemManagerController extends ControllerBase
$this->eventDispatcher->notifyEvent('show.itemlist.items', new Event($this));
$this->tabsGridHelper->renderTabs(Acl::getActionRoute(ActionsInterface::ITEMS_MANAGE), Request::analyze('tabIndex', 0));
$this->tabsGridHelper->renderTabs(Acl::getActionRoute(ActionsInterface::ITEMS_MANAGE), Request::analyzeInt('tabIndex', 0));
$this->view();
}

View File

@@ -31,11 +31,11 @@ use SP\Core\Acl\ActionsInterface;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\DataModel\NotificationData;
use SP\Forms\NotificationForm;
use SP\Http\JsonResponse;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\NotificationForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Mvc\View\Components\SelectItemAdapter;
use SP\Services\Notification\NotificationService;

View File

@@ -31,12 +31,12 @@ use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\SPException;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\PublicLinkListData;
use SP\Forms\PublicLinkForm;
use SP\Http\JsonResponse;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\PublicLinkForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Mvc\View\Components\SelectItemAdapter;
use SP\Services\Account\AccountService;
@@ -71,7 +71,7 @@ class PublicLinkController extends ControllerBase implements CrudControllerInter
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);

View File

@@ -45,8 +45,8 @@ class ResourceController extends SimpleControllerBase
*/
public function cssAction()
{
$file = Request::analyze('f');
$base = Request::analyze('b');
$file = Request::analyzeString('f');
$base = Request::analyzeString('b');
$minify = $this->dic->get(Minify::class);
@@ -77,8 +77,8 @@ class ResourceController extends SimpleControllerBase
*/
public function jsAction()
{
$file = Request::analyze('f');
$base = Request::analyze('b');
$file = Request::analyzeString('f');
$base = Request::analyzeString('b');
$minify = $this->dic->get(Minify::class);
@@ -91,7 +91,7 @@ class ResourceController extends SimpleControllerBase
$minify->setType(Minify::FILETYPE_JS)
->setBase(PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js');
$group = Request::analyze('g', 0);
$group = Request::analyzeInt('g', 0);
if ($group === 0) {
$minify->addFiles([

View File

@@ -30,12 +30,12 @@ use SP\Core\Acl\ActionsInterface;
use SP\Core\Events\Event;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\TagData;
use SP\Forms\TagForm;
use SP\Http\JsonResponse;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\TagForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Services\Tag\TagService;
@@ -68,7 +68,7 @@ class TagController extends ControllerBase implements CrudControllerInterface
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);

View File

@@ -101,9 +101,7 @@ trait ItemTrait
*/
protected function addCustomFieldsForItem($moduleId, $itemId)
{
$customFields = Request::analyzeArray('customfield');
if ($customFields !== false) {
if ($customFields = Request::analyzeArray('customfield')) {
$customFieldData = new CustomFieldData();
$customFieldData->setId($itemId);
$customFieldData->setModuleId($moduleId);
@@ -156,9 +154,7 @@ trait ItemTrait
*/
protected function updateCustomFieldsForItem($moduleId, $itemId)
{
$customFields = Request::analyzeArray('customfield');
if ($customFields !== false) {
if ($customFields = Request::analyzeArray('customfield')) {
$customFieldData = new CustomFieldData();
$customFieldData->setId($itemId);
$customFieldData->setModuleId($moduleId);

View File

@@ -31,12 +31,12 @@ use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\ValidationException;
use SP\Core\SessionUtil;
use SP\DataModel\UserData;
use SP\Forms\UserForm;
use SP\Http\JsonResponse;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\UserForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Mvc\View\Components\SelectItemAdapter;
use SP\Providers\Mail\Mailer;
@@ -74,7 +74,7 @@ class UserController extends ControllerBase implements CrudControllerInterface
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);
@@ -340,7 +340,7 @@ class UserController extends ControllerBase implements CrudControllerInterface
try {
$form = new UserForm($id);
$form->setIsLdap(Request::analyze('isLdap', 0));
$form->setIsLdap(Request::analyzeInt('isLdap', 0));
$form->validate(ActionsInterface::USER_EDIT);
$itemData = $form->getItemData();

View File

@@ -30,12 +30,12 @@ use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\UserGroupData;
use SP\Forms\UserGroupForm;
use SP\Http\JsonResponse;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\UserGroupForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Mvc\View\Components\SelectItemAdapter;
use SP\Services\User\UserService;
@@ -75,7 +75,7 @@ class UserGroupController extends ControllerBase implements CrudControllerInterf
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);

View File

@@ -82,8 +82,8 @@ class UserPassResetController extends ControllerBase
try {
$this->checkTracking();
$login = Request::analyze('login');
$email = Request::analyze('email');
$login = Request::analyzeString('login');
$email = Request::analyzeEmail('email');
$userLoginResponse = $this->dic->get(UserService::class)->getByLogin($login);
@@ -97,7 +97,7 @@ class UserPassResetController extends ControllerBase
$hash = $this->dic->get(UserPassRecoverService::class)->requestForUserId($userLoginResponse->getId());
$this->eventDispatcher->notifyEvent('userPassReset.request',
$this->eventDispatcher->notifyEvent('request.user.passReset',
new Event($this, EventMessage::factory()
->addDescription(__u('Recuperación de Clave'))
->addDetail(__u('Solicitado para'), sprintf('%s (%s)', $login, $email)))
@@ -174,7 +174,7 @@ class UserPassResetController extends ControllerBase
throw new ValidationException(__u('Las claves no coinciden'));
}
$hash = Request::analyze('hash');
$hash = Request::analyzeString('hash');
$userPassRecoverService = $this->dic->get(UserPassRecoverService::class);
$userId = $userPassRecoverService->getUserIdForHash($hash);
@@ -182,7 +182,7 @@ class UserPassResetController extends ControllerBase
$this->dic->get(UserService::class)->updatePass($userId, $pass);
$this->eventDispatcher->notifyEvent('edit.user.pass',
$this->eventDispatcher->notifyEvent('edit.user.password',
new Event($this, EventMessage::factory()
->addDescription(__u('Clave actualizada'))
->addDetail(__u('Usuario'), $userId))

View File

@@ -31,12 +31,12 @@ use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\ProfileData;
use SP\DataModel\UserProfileData;
use SP\Forms\UserProfileForm;
use SP\Http\JsonResponse;
use SP\Http\Request;
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Modules\Web\Forms\UserProfileForm;
use SP\Mvc\Controller\CrudControllerInterface;
use SP\Services\UserProfile\UserProfileService;
@@ -69,7 +69,7 @@ class UserProfileController extends ControllerBase implements CrudControllerInte
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', Request::analyze('activetab', 0));
$this->view->assign('index', Request::analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
$this->returnJsonResponseData(['html' => $this->render()]);

View File

@@ -52,14 +52,14 @@ class UserSettingsGeneralController extends SimpleControllerBase
$userPreferencesData = clone $userData->getPreferences();
$userPreferencesData->setUserId($userData->getId());
$userPreferencesData->setLang(Request::analyze('userlang'));
$userPreferencesData->setTheme(Request::analyze('usertheme', 'material-blue'));
$userPreferencesData->setResultsPerPage(Request::analyze('resultsperpage', 12));
$userPreferencesData->setAccountLink(Request::analyze('account_link', false, false, true));
$userPreferencesData->setSortViews(Request::analyze('sort_views', false, false, true));
$userPreferencesData->setTopNavbar(Request::analyze('top_navbar', false, false, true));
$userPreferencesData->setOptionalActions(Request::analyze('optional_actions', false, false, true));
$userPreferencesData->setResultsAsCards(Request::analyze('resultsascards', false, false, true));
$userPreferencesData->setLang(Request::analyzeString('userlang'));
$userPreferencesData->setTheme(Request::analyzeString('usertheme', 'material-blue'));
$userPreferencesData->setResultsPerPage(Request::analyzeInt('resultsperpage', 12));
$userPreferencesData->setAccountLink(Request::analyzeBool('account_link', false));
$userPreferencesData->setSortViews(Request::analyzeBool('sort_views', false));
$userPreferencesData->setTopNavbar(Request::analyzeBool('top_navbar', false));
$userPreferencesData->setOptionalActions(Request::analyzeBool('optional_actions', false));
$userPreferencesData->setResultsAsCards(Request::analyzeBool('resultsascards', false));
try {
$this->userService->updatePreferencesById($userData->getId(), $userPreferencesData);

View File

@@ -60,7 +60,7 @@ class UserSettingsManagerController extends ControllerBase
$this->eventDispatcher->notifyEvent('show.userSettings', new Event($this));
$this->tabsHelper->renderTabs(Acl::getActionRoute(ActionsInterface::USERSETTINGS), Request::analyze('tabIndex', 0));
$this->tabsHelper->renderTabs(Acl::getActionRoute(ActionsInterface::USERSETTINGS), Request::analyzeInt('tabIndex', 0));
$this->view();
}

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,12 +22,11 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Account\AccountRequest;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
use SP\Core\SessionFactory;
use SP\Http\Request;
/**
@@ -80,36 +79,36 @@ class AccountForm extends FormBase implements FormInterface
{
$this->accountRequest = new AccountRequest();
$this->accountRequest->id = $this->itemId;
$this->accountRequest->name = Request::analyze('name');
$this->accountRequest->clientId = Request::analyze('clientId', 0);
$this->accountRequest->categoryId = Request::analyze('categoryId', 0);
$this->accountRequest->login = Request::analyze('login');
$this->accountRequest->url = Request::analyze('url');
$this->accountRequest->notes = Request::analyze('notes');
$this->accountRequest->userEditId = SessionFactory::getUserData()->getId();
$this->accountRequest->otherUserEdit = (int)Request::analyze('otherUserEditEnabled', 0, false, 1);
$this->accountRequest->otherUserGroupEdit = (int)Request::analyze('otherUserGroupEditEnabled', 0, false, 1);
$this->accountRequest->name = Request::analyzeString('name');
$this->accountRequest->clientId = Request::analyzeInt('clientId', 0);
$this->accountRequest->categoryId = Request::analyzeInt('categoryId', 0);
$this->accountRequest->login = Request::analyzeString('login');
$this->accountRequest->url = Request::analyzeString('url');
$this->accountRequest->notes = Request::analyzeString('notes');
$this->accountRequest->userEditId = $this->session->getUserData()->getId();
$this->accountRequest->otherUserEdit = (int)Request::analyzeBool('otherUserEditEnabled', false);
$this->accountRequest->otherUserGroupEdit = (int)Request::analyzeBool('otherUserGroupEditEnabled', false);
$this->accountRequest->pass = Request::analyzeEncrypted('pass');
$this->accountRequest->isPrivate = (int)Request::analyze('privateEnabled', 0, false, 1);
$this->accountRequest->isPrivateGroup = (int)Request::analyze('privateGroupEnabled', 0, false, 1);
$this->accountRequest->passDateChange = Request::analyze('passworddatechange_unix', 0);
$this->accountRequest->parentId = Request::analyze('parentAccountId', 0);
$this->accountRequest->userGroupId = Request::analyze('mainUserGroupId', 0);
$this->accountRequest->isPrivate = (int)Request::analyzeBool('privateEnabled', false);
$this->accountRequest->isPrivateGroup = (int)Request::analyzeBool('privateGroupEnabled', false);
$this->accountRequest->passDateChange = Request::analyzeInt('passworddatechange_unix');
$this->accountRequest->parentId = Request::analyzeInt('parentAccountId');
$this->accountRequest->userGroupId = Request::analyzeInt('mainUserGroupId');
// Arrays
$accountOtherGroups = Request::analyze('otherUserGroups', 0);
$accountOtherUsers = Request::analyze('otherUsers', 0);
$accountTags = Request::analyze('tags', 0);
$accountOtherGroups = Request::analyzeArray('otherUserGroups');
$accountOtherUsers = Request::analyzeArray('otherUsers');
$accountTags = Request::analyzeArray('tags');
if (is_array($accountOtherUsers)) {
if ($accountOtherUsers) {
$this->accountRequest->users = $accountOtherUsers;
}
if (is_array($accountOtherGroups)) {
if ($accountOtherGroups) {
$this->accountRequest->userGroups = $accountOtherGroups;
}
if (is_array($accountTags)) {
if ($accountTags) {
$this->accountRequest->tags = $accountTags;
}
}

View File

@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
@@ -32,7 +32,7 @@ use SP\Http\Request;
/**
* Class ApiTokenForm
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
class AuthTokenForm extends FormBase implements FormInterface
{
@@ -72,12 +72,12 @@ class AuthTokenForm extends FormBase implements FormInterface
*/
protected function analyzeRequestData()
{
$this->refresh = (bool)Request::analyze('refreshtoken', 0, false, 1);
$this->refresh = Request::analyzeBool('refreshtoken', false);
$this->authTokenData = new AuthTokenData();
$this->authTokenData->setId($this->itemId);
$this->authTokenData->setUserId(Request::analyze('users', 0));
$this->authTokenData->setActionId(Request::analyze('actions', 0));
$this->authTokenData->setUserId(Request::analyzeInt('users'));
$this->authTokenData->setActionId(Request::analyzeInt('actions'));
$this->authTokenData->setHash(Request::analyzeEncrypted('pass'));
}

View File

@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
@@ -32,7 +32,7 @@ use SP\Http\Request;
/**
* Class CategoryForm
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
class CategoryForm extends FormBase implements FormInterface
{
@@ -70,8 +70,8 @@ class CategoryForm extends FormBase implements FormInterface
{
$this->categoryData = new CategoryData();
$this->categoryData->setId($this->itemId);
$this->categoryData->setName(Request::analyze('name'));
$this->categoryData->setDescription(Request::analyze('description'));
$this->categoryData->setName(Request::analyzeString('name'));
$this->categoryData->setDescription(Request::analyzeString('description'));
}
/**

View File

@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
@@ -32,7 +32,7 @@ use SP\Http\Request;
/**
* Class ClientForm
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
class ClientForm extends FormBase implements FormInterface
{
@@ -70,9 +70,9 @@ class ClientForm extends FormBase implements FormInterface
{
$this->clientData = new ClientData();
$this->clientData->setId($this->itemId);
$this->clientData->setName(Request::analyze('name'));
$this->clientData->setDescription(Request::analyze('description'));
$this->clientData->setIsGlobal(Request::analyze('isglobal', 0, false, 1));
$this->clientData->setName(Request::analyzeString('name'));
$this->clientData->setDescription(Request::analyzeString('description'));
$this->clientData->setIsGlobal(Request::analyzeBool('isglobal', false));
}
/**

View File

@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
@@ -32,7 +32,7 @@ use SP\Http\Request;
/**
* Class CustomFieldDefForm
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
class CustomFieldDefForm extends FormBase implements FormInterface
{
@@ -70,11 +70,11 @@ class CustomFieldDefForm extends FormBase implements FormInterface
{
$this->customFieldDefData = new CustomFieldDefinitionData();
$this->customFieldDefData->setId($this->itemId);
$this->customFieldDefData->setName(Request::analyze('name'));
$this->customFieldDefData->setTypeId(Request::analyze('type', 0));
$this->customFieldDefData->setModuleId(Request::analyze('module', 0));
$this->customFieldDefData->setHelp(Request::analyze('help'));
$this->customFieldDefData->setRequired(Request::analyze('required', false, false, true));
$this->customFieldDefData->setName(Request::analyzeString('name'));
$this->customFieldDefData->setTypeId(Request::analyzeInt('type'));
$this->customFieldDefData->setModuleId(Request::analyzeInt('module'));
$this->customFieldDefData->setHelp(Request::analyzeString('help'));
$this->customFieldDefData->setRequired(Request::analyzeBool('required', false));
}
/**

View File

@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Config\Config;
use SP\Config\ConfigData;
@@ -32,7 +32,7 @@ use SP\Core\Traits\InjectableTrait;
/**
* Class FormBase
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
abstract class FormBase
{

View File

@@ -22,12 +22,12 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
/**
* Interface FormInterface
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
interface FormInterface
{

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
@@ -33,7 +33,7 @@ use SP\Http\Request;
/**
* Class NotificationForm
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
class NotificationForm extends FormBase implements FormInterface
{
@@ -71,15 +71,15 @@ class NotificationForm extends FormBase implements FormInterface
{
$this->notificationData = new NotificationData();
$this->notificationData->setId($this->itemId);
$this->notificationData->setType(Request::analyze('notification_type'));
$this->notificationData->setComponent(Request::analyze('notification_component'));
$this->notificationData->setDescription(NoticeMessage::factory()->addDescription(Request::analyze('notification_description')));
$this->notificationData->setUserId(Request::analyze('notification_user', 0));
$this->notificationData->setChecked(Request::analyze('notification_checkout', 0, false, 1));
$this->notificationData->setType(Request::analyzeString('notification_type'));
$this->notificationData->setComponent(Request::analyzeString('notification_component'));
$this->notificationData->setDescription(NoticeMessage::factory()->addDescription(Request::analyzeString('notification_description')));
$this->notificationData->setUserId(Request::analyzeInt('notification_user'));
$this->notificationData->setChecked(Request::analyzeBool('notification_checkout', false));
if ($this->session->getUserData()->getIsAdminApp() && $this->notificationData->getUserId() === 0) {
$this->notificationData->setOnlyAdmin(Request::analyze('notification_onlyadmin', 0, false, 1));
$this->notificationData->setSticky(Request::analyze('notification_sticky', 0, false, 1));
$this->notificationData->setOnlyAdmin(Request::analyzeBool('notification_onlyadmin', false));
$this->notificationData->setSticky(Request::analyzeBool('notification_sticky', false));
}
}

View File

@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
@@ -34,7 +34,7 @@ use SP\Util\Util;
/**
* Class PublicLinkForm
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
class PublicLinkForm extends FormBase implements FormInterface
{
@@ -75,8 +75,8 @@ class PublicLinkForm extends FormBase implements FormInterface
$this->publicLinkData = new PublicLinkData();
$this->publicLinkData->setId($this->itemId);
$this->publicLinkData->setTypeId(PublicLink::TYPE_ACCOUNT);
$this->publicLinkData->setItemId(Request::analyze('accountId', 0));
$this->publicLinkData->setNotify(Request::analyze('notify', false, false, true));
$this->publicLinkData->setItemId(Request::analyzeInt('accountId'));
$this->publicLinkData->setNotify(Request::analyzeBool('notify', false));
$this->publicLinkData->setHash(Util::generateRandomBytes());
}

View File

@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
@@ -32,7 +32,7 @@ use SP\Http\Request;
/**
* Class TagForm
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
class TagForm extends FormBase implements FormInterface
{
@@ -70,7 +70,7 @@ class TagForm extends FormBase implements FormInterface
{
$this->tagData = new TagData();
$this->tagData->setId($this->itemId);
$this->tagData->setName(Request::analyze('name'));
$this->tagData->setName(Request::analyzeString('name'));
}
/**

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
@@ -33,7 +33,7 @@ use SP\Http\Request;
/**
* Class UserForm
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
class UserForm extends FormBase implements FormInterface
{
@@ -86,17 +86,17 @@ class UserForm extends FormBase implements FormInterface
{
$this->userData = new UserData();
$this->userData->setId($this->itemId);
$this->userData->setName(Request::analyze('name'));
$this->userData->setLogin(Request::analyze('login'));
$this->userData->setSsoLogin(Request::analyze('login_sso'));
$this->userData->setEmail(Request::analyze('email'));
$this->userData->setNotes(Request::analyze('notes'));
$this->userData->setUserGroupId(Request::analyze('groupid', 0));
$this->userData->setUserProfileId(Request::analyze('profileid', 0));
$this->userData->setIsAdminApp(Request::analyze('adminapp', 0, false, 1));
$this->userData->setIsAdminAcc(Request::analyze('adminacc', 0, false, 1));
$this->userData->setIsDisabled(Request::analyze('disabled', 0, false, 1));
$this->userData->setIsChangePass(Request::analyze('changepass', 0, false, 1));
$this->userData->setName(Request::analyzeString('name'));
$this->userData->setLogin(Request::analyzeString('login'));
$this->userData->setSsoLogin(Request::analyzeString('login_sso'));
$this->userData->setEmail(Request::analyzeEmail('email'));
$this->userData->setNotes(Request::analyzeString('notes'));
$this->userData->setUserGroupId(Request::analyzeInt('groupid'));
$this->userData->setUserProfileId(Request::analyzeInt('profileid'));
$this->userData->setIsAdminApp(Request::analyzeBool('adminapp', false));
$this->userData->setIsAdminAcc(Request::analyzeBool('adminacc', false));
$this->userData->setIsDisabled(Request::analyzeBool('disabled', false));
$this->userData->setIsChangePass(Request::analyzeBool('changepass', false));
$this->userData->setPass(Request::analyzeEncrypted('pass'));
}

View File

@@ -22,7 +22,7 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
@@ -32,7 +32,7 @@ use SP\Http\Request;
/**
* Class UserGroupForm
*
* @package SP\Forms
* @package SP\Modules\Web\Forms
*/
class UserGroupForm extends FormBase implements FormInterface
{
@@ -70,9 +70,9 @@ class UserGroupForm extends FormBase implements FormInterface
{
$this->groupData = new UserGroupData();
$this->groupData->setId($this->itemId);
$this->groupData->setName(Request::analyze('name'));
$this->groupData->setDescription(Request::analyze('description'));
$this->groupData->setUsers(Request::analyze('users', 0));
$this->groupData->setName(Request::analyzeString('name'));
$this->groupData->setDescription(Request::analyzeString('description'));
$this->groupData->setUsers(Request::analyzeArray('users'));
}
/**

View File

@@ -0,0 +1,126 @@
<?php
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Modules\Web\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\ProfileData;
use SP\DataModel\UserProfileData;
use SP\Http\Request;
/**
* Class UserProfileForm
*
* @package SP\Modules\Web\Forms
*/
class UserProfileForm extends FormBase implements FormInterface
{
/**
* @var UserProfileData
*/
protected $userProfileData;
/**
* Validar el formulario
*
* @param $action
* @return bool
* @throws \SP\Core\Exceptions\ValidationException
*/
public function validate($action)
{
switch ($action) {
case ActionsInterface::PROFILE_CREATE:
case ActionsInterface::PROFILE_EDIT:
$this->analyzeRequestData();
$this->checkCommon();
break;
}
return true;
}
/**
* Analizar los datos de la petición HTTP
*
* @return void
*/
protected function analyzeRequestData()
{
$profileData = new ProfileData();
$profileData->setAccAdd(Request::analyzeBool('profile_accadd', false));
$profileData->setAccView(Request::analyzeBool('profile_accview', false));
$profileData->setAccViewPass(Request::analyzeBool('profile_accviewpass', false));
$profileData->setAccViewHistory(Request::analyzeBool('profile_accviewhistory', false));
$profileData->setAccEdit(Request::analyzeBool('profile_accedit', false));
$profileData->setAccEditPass(Request::analyzeBool('profile_acceditpass', false));
$profileData->setAccDelete(Request::analyzeBool('profile_accdel', false));
$profileData->setAccFiles(Request::analyzeBool('profile_accfiles', false));
$profileData->setAccPublicLinks(Request::analyzeBool('profile_accpublinks', false));
$profileData->setAccPrivate(Request::analyzeBool('profile_accprivate', false));
$profileData->setAccPrivateGroup(Request::analyzeBool('profile_accprivategroup', false));
$profileData->setAccPermission(Request::analyzeBool('profile_accpermissions', false));
$profileData->setAccGlobalSearch(Request::analyzeBool('profile_accglobalsearch', false));
$profileData->setConfigGeneral(Request::analyzeBool('profile_config', false));
$profileData->setConfigEncryption(Request::analyzeBool('profile_configmpw', false));
$profileData->setConfigBackup(Request::analyzeBool('profile_configback', false));
$profileData->setConfigImport(Request::analyzeBool('profile_configimport', false));
$profileData->setMgmCategories(Request::analyzeBool('profile_categories', false));
$profileData->setMgmCustomers(Request::analyzeBool('profile_customers', false));
$profileData->setMgmCustomFields(Request::analyzeBool('profile_customfields', false));
$profileData->setMgmUsers(Request::analyzeBool('profile_users', false));
$profileData->setMgmGroups(Request::analyzeBool('profile_groups', false));
$profileData->setMgmProfiles(Request::analyzeBool('profile_profiles', false));
$profileData->setMgmApiTokens(Request::analyzeBool('profile_apitokens', false));
$profileData->setMgmPublicLinks(Request::analyzeBool('profile_publinks', false));
$profileData->setMgmAccounts(Request::analyzeBool('profile_accounts', false));
$profileData->setMgmFiles(Request::analyzeBool('profile_files', false));
$profileData->setMgmTags(Request::analyzeBool('profile_tags', false));
$profileData->setEvl(Request::analyzeBool('profile_eventlog', false));
$this->userProfileData = new UserProfileData();
$this->userProfileData->setName(Request::analyzeString('profile_name'));
$this->userProfileData->setId($this->itemId);
$this->userProfileData->setProfile($profileData);
}
/**
* @throws ValidationException
*/
protected function checkCommon()
{
if (!$this->userProfileData->getName()) {
throw new ValidationException(__u('Es necesario un nombre de perfil'));
}
}
/**
* @return UserProfileData
*/
public function getItemData()
{
return $this->userProfileData;
}
}

View File

@@ -46,7 +46,7 @@
<input type="hidden" name="gsearch" value="<?php echo $searchGlobal; ?>">
<?php endif; ?>
<select id="customer" name="customer" class="select-box select-box-deselect" tabindex="3">
<select id="client" name="client" class="select-box select-box-deselect" tabindex="3">
<option value=""><?php echo __('Seleccionar Cliente'); ?></option>
<?php /** @var \SP\Mvc\View\Components\SelectItem[] $clients */
foreach ($clients as $client): ?>

View File

@@ -43,7 +43,6 @@ use SP\Core\Exceptions\SPException;
use SP\Core\Language;
use SP\Core\Plugin\PluginUtil;
use SP\Core\Session\Session;
use SP\Core\SessionUtil;
use SP\Core\UI\Theme;
use SP\Core\Upgrade\Upgrade;
use SP\Http\Request;
@@ -541,8 +540,7 @@ class Bootstrap
if ($check === true
|| Checks::isAjax($this->router)
|| Request::analyze('nodbupgrade', 0) === 1
|| (Request::analyze('a') === 'upgrade' && Request::analyze('type') !== '')
|| Request::analyzeInt('nodbupgrade') === 1
|| (self::$LOCK > 0 && $this->session->isLoggedIn() && self::$LOCK === $this->session->getUserData()->getId())
) {
return true;
@@ -570,7 +568,7 @@ class Bootstrap
$this->router->response()->cookie(session_name(), '', time() - 42000);
}
SessionUtil::restart();
Session::restart();
} else {
$sidStartTime = $this->session->getSidStartTime();
@@ -594,7 +592,7 @@ class Bootstrap
} catch (CryptoException $e) {
debugLog($e->getMessage());
SessionUtil::restart();
Session::restart();
return;
}
}

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -224,7 +224,7 @@ class ConfigData implements JsonSerializable
/**
* @var string
*/
private $mailFrom ;
private $mailFrom;
/**
* @var string
*/
@@ -998,19 +998,15 @@ class ConfigData implements JsonSerializable
*/
public function getFilesAllowedExts()
{
return is_array($this->filesAllowedExts) ? $this->filesAllowedExts : [];
return (array)$this->filesAllowedExts;
}
/**
* @param array $filesAllowedExts
* @return $this
*/
public function setFilesAllowedExts($filesAllowedExts = [])
public function setFilesAllowedExts(array $filesAllowedExts = [])
{
if (!is_array($filesAllowedExts)) {
$filesAllowedExts = ConfigUtil::filesExtsAdapter($filesAllowedExts);
}
$this->filesAllowedExts = $filesAllowedExts;
return $this;

View File

@@ -40,17 +40,15 @@ class ConfigUtil
* @param $filesAllowedExts
* @return array
*/
public static function filesExtsAdapter(&$filesAllowedExts)
public static function filesExtsAdapter($filesAllowedExts)
{
$exts = explode(',', $filesAllowedExts);
array_walk($exts, function (&$value) {
return array_map(function ($value) {
if (preg_match('/[^a-z0-9_-]+/i', $value)) {
$value = null;
return null;
}
});
return $exts;
return strtoupper($value);
}, explode(',', $filesAllowedExts));
}
/**

View File

@@ -2,8 +2,8 @@
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -37,6 +37,7 @@ use SP\Services\User\UserLoginResponse;
*/
class Session
{
private static $isReset = false;
private static $isLocked = false;
/**
@@ -59,6 +60,18 @@ class Session
self::$isLocked = true;
}
/**
* Destruir la sesión y reiniciar
*/
public static function restart()
{
self::$isReset = true;
session_unset();
session_destroy();
session_start();
}
/**
* Devuelve el tema visual utilizado en sysPass
*
@@ -227,10 +240,8 @@ class Session
*/
public function isLoggedIn()
{
$userData = $this->getUserData();
return $userData->getLogin()
&& is_object($userData->getPreferences());
return self::$isReset === false && $this->getUserData()->getLogin()
&& is_object($this->getUserData()->getPreferences());
}
/**

View File

@@ -146,14 +146,4 @@ class SessionUtil
$session->setSidStartTime(time());
}
/**
* Destruir la sesión y reiniciar
*/
public static function restart()
{
session_unset();
session_destroy();
session_start();
}
}

View File

@@ -137,6 +137,6 @@ class ClientData extends DataModelBase implements DataModelInterface
*/
public function setIsGlobal($isGlobal)
{
$this->isGlobal = (bool)$isGlobal;
$this->isGlobal = (int)$isGlobal;
}
}

View File

@@ -1,126 +0,0 @@
<?php
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Forms;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Exceptions\ValidationException;
use SP\DataModel\ProfileData;
use SP\DataModel\UserProfileData;
use SP\Http\Request;
/**
* Class UserProfileForm
*
* @package SP\Forms
*/
class UserProfileForm extends FormBase implements FormInterface
{
/**
* @var UserProfileData
*/
protected $userProfileData;
/**
* Validar el formulario
*
* @param $action
* @return bool
* @throws \SP\Core\Exceptions\ValidationException
*/
public function validate($action)
{
switch ($action) {
case ActionsInterface::PROFILE_CREATE:
case ActionsInterface::PROFILE_EDIT:
$this->analyzeRequestData();
$this->checkCommon();
break;
}
return true;
}
/**
* Analizar los datos de la petición HTTP
*
* @return void
*/
protected function analyzeRequestData()
{
$profileData = new ProfileData();
$profileData->setAccAdd(Request::analyze('profile_accadd', 0, false, 1));
$profileData->setAccView(Request::analyze('profile_accview', 0, false, 1));
$profileData->setAccViewPass(Request::analyze('profile_accviewpass', 0, false, 1));
$profileData->setAccViewHistory(Request::analyze('profile_accviewhistory', 0, false, 1));
$profileData->setAccEdit(Request::analyze('profile_accedit', 0, false, 1));
$profileData->setAccEditPass(Request::analyze('profile_acceditpass', 0, false, 1));
$profileData->setAccDelete(Request::analyze('profile_accdel', 0, false, 1));
$profileData->setAccFiles(Request::analyze('profile_accfiles', 0, false, 1));
$profileData->setAccPublicLinks(Request::analyze('profile_accpublinks', 0, false, 1));
$profileData->setAccPrivate(Request::analyze('profile_accprivate', 0, false, 1));
$profileData->setAccPrivateGroup(Request::analyze('profile_accprivategroup', 0, false, 1));
$profileData->setAccPermission(Request::analyze('profile_accpermissions', 0, false, 1));
$profileData->setAccGlobalSearch(Request::analyze('profile_accglobalsearch', 0, false, 1));
$profileData->setConfigGeneral(Request::analyze('profile_config', 0, false, 1));
$profileData->setConfigEncryption(Request::analyze('profile_configmpw', 0, false, 1));
$profileData->setConfigBackup(Request::analyze('profile_configback', 0, false, 1));
$profileData->setConfigImport(Request::analyze('profile_configimport', 0, false, 1));
$profileData->setMgmCategories(Request::analyze('profile_categories', 0, false, 1));
$profileData->setMgmCustomers(Request::analyze('profile_customers', 0, false, 1));
$profileData->setMgmCustomFields(Request::analyze('profile_customfields', 0, false, 1));
$profileData->setMgmUsers(Request::analyze('profile_users', 0, false, 1));
$profileData->setMgmGroups(Request::analyze('profile_groups', 0, false, 1));
$profileData->setMgmProfiles(Request::analyze('profile_profiles', 0, false, 1));
$profileData->setMgmApiTokens(Request::analyze('profile_apitokens', 0, false, 1));
$profileData->setMgmPublicLinks(Request::analyze('profile_publinks', 0, false, 1));
$profileData->setMgmAccounts(Request::analyze('profile_accounts', 0, false, 1));
$profileData->setMgmFiles(Request::analyze('profile_files', 0, false, 1));
$profileData->setMgmTags(Request::analyze('profile_tags', 0, false, 1));
$profileData->setEvl(Request::analyze('profile_eventlog', 0, false, 1));
$this->userProfileData = new UserProfileData();
$this->userProfileData->setName(Request::analyze('profile_name'));
$this->userProfileData->setId($this->itemId);
$this->userProfileData->setProfile($profileData);
}
/**
* @throws ValidationException
*/
protected function checkCommon()
{
if (!$this->userProfileData->getName()) {
throw new ValidationException(__u('Es necesario un nombre de perfil'));
}
}
/**
* @return UserProfileData
*/
public function getItemData()
{
return $this->userProfileData;
}
}

View File

@@ -111,7 +111,7 @@ class Request
*/
public static function analyzeEncrypted($param)
{
$encryptedData = self::analyze($param, '', false, false, false);
$encryptedData = self::analyzeString($param);
if ($encryptedData === '') {
return '';
@@ -133,6 +133,34 @@ class Request
return $clearData;
}
/**
* @param $param
* @param $default
* @return string
*/
public static function analyzeString($param, $default = null)
{
if (!isset($_REQUEST[$param])) {
return (string)$default;
}
return filter_var($_REQUEST[$param], FILTER_SANITIZE_STRING);
}
/**
* @param $param
* @param $default
* @return string
*/
public static function analyzeEmail($param, $default = null)
{
if (!isset($_REQUEST[$param])) {
return (string)$default;
}
return filter_var($_REQUEST[$param], FILTER_SANITIZE_EMAIL);
}
/**
* Obtener los valores de variables $_GET y $_POST
* y devolverlos limpios con el tipo correcto o esperado.
@@ -199,7 +227,7 @@ class Request
*/
public static function analyzeArray($param)
{
if (is_array($_REQUEST[$param])) {
if (isset($_REQUEST[$param]) && is_array($_REQUEST[$param])) {
return array_map(function ($value) {
if (is_numeric($value)) {
return (int)filter_var($value, FILTER_SANITIZE_NUMBER_INT);
@@ -209,16 +237,15 @@ class Request
}, $_REQUEST[$param]);
}
return false;
return null;
}
/**
* @param $param
* @param $default
* @return int
*/
public static function analyzeInt($param, $default = 0)
public static function analyzeInt($param, $default = null)
{
if (!isset($_REQUEST[$param])) {
return (int)$default;
@@ -227,26 +254,12 @@ class Request
return (int)filter_var($_REQUEST[$param], FILTER_SANITIZE_NUMBER_INT);
}
/**
* @param $param
* @param $default
* @return string
*/
public static function analyzeString($param, $default = '')
{
if (!isset($_REQUEST[$param])) {
return (string)$default;
}
return filter_var($_REQUEST[$param], FILTER_SANITIZE_STRING);
}
/**
* @param $param
* @param $default
* @return bool
*/
public static function analyzeBool($param, $default = false)
public static function analyzeBool($param, $default = null)
{
if (!isset($_REQUEST[$param])) {
return (bool)$default;

View File

@@ -73,7 +73,7 @@ trait ControllerTrait
*/
protected function checkSecurityToken(Session $session)
{
$sk = Request::analyze('sk');
$sk = Request::analyzeString('sk');
$sessionKey = $session->getSecurityKey();
if (!$sk || (null !== $sessionKey && $sessionKey !== $sk)) {

View File

@@ -94,6 +94,7 @@ class LogHandler extends Provider implements EventReceiver
{
$eventlogData = new EventlogData();
$eventlogData->setAction($eventType);
$eventlogData->setLevel('INFO');
if (($e = $event->getSource()) instanceof \Exception) {
/** @var \Exception $e */
@@ -101,13 +102,6 @@ class LogHandler extends Provider implements EventReceiver
$eventlogData->setLevel('ERROR');
} elseif (($eventMessage = $event->getEventMessage()) !== null) {
$eventlogData->setDescription($eventMessage->composeText());
$eventlogData->setLevel('INFO');
}
if (($e = $event->getSource()) instanceof \Exception) {
$eventlogData->setLevel('INFO');
/** @var \Exception $e */
$eventlogData->setDescription($e->getMessage());
}
try {

View File

@@ -133,7 +133,7 @@ class LoginService extends Service
*/
public function doLogin()
{
$this->userLoginData->setLoginUser(Request::analyze('user'));
$this->userLoginData->setLoginUser(Request::analyzeString('user'));
$this->userLoginData->setLoginPass(Request::analyzeEncrypted('pass'));
if ($this->trackService->checkTracking($this->trackRequest)) {