mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-02-20 01:41:27 +01:00
* [ADD] Work in progress
* [ADD] Using URL routing * [ADD] Using dependency injection * [MOD] Big app structure changes
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -45,11 +45,12 @@ crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
backup/*
|
||||
config/*
|
||||
app/cache/*
|
||||
app/backup/*
|
||||
app/config/*
|
||||
res/
|
||||
tools/
|
||||
tmp/
|
||||
inc/Plugins/*
|
||||
app/temp/*
|
||||
app/modules/web/plugins/*
|
||||
|
||||
!.blank
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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/>.
|
||||
*/
|
||||
|
||||
use SP\Controller\ItemListController;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Http\Request;
|
||||
use SP\Http\Response;
|
||||
use SP\Util\Checks;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
if (!Init::isLoggedIn()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Checks::fileIsEnabled()) {
|
||||
echo __('Gestión de archivos deshabilitada');
|
||||
return false;
|
||||
}
|
||||
|
||||
$sk = Request::analyze('sk', false);
|
||||
|
||||
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
Response::printHtmlError(__('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
$Controller = new ItemListController();
|
||||
$Controller->getAccountFiles();
|
||||
$Controller->view();
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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/>.
|
||||
*/
|
||||
|
||||
use SP\Controller\AccountSearchController;
|
||||
use SP\Core\Init;
|
||||
use SP\Http\Request;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Http\Response;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
if (!Init::isLoggedIn()) {
|
||||
Response::printJson(__('La sesión no se ha iniciado o ha caducado'), 10);
|
||||
}
|
||||
|
||||
$sk = Request::analyze('sk', false);
|
||||
|
||||
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
Response::printJson(__('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
$Controller = new AccountSearchController();
|
||||
$Controller->setIsAjax(true);
|
||||
$Controller->getSearch();
|
||||
|
||||
$data = [
|
||||
'sk' => SessionUtil::getSessionKey(),
|
||||
'html' => $Controller->render()
|
||||
];
|
||||
|
||||
Response::printJson($data, 0);
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
|
||||
@@ -25,17 +25,15 @@
|
||||
use SP\Controller\EventlogController;
|
||||
use SP\Core\Init;
|
||||
use SP\Http\Request;
|
||||
use SP\Util\Util;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
if (!Init::isLoggedIn()) {
|
||||
\SP\Util\Util::logout();
|
||||
}
|
||||
|
||||
$Controller = new EventlogController();
|
||||
$Controller->checkLoggedIn();
|
||||
$Controller->doAction();
|
||||
$Controller->view();
|
||||
@@ -23,10 +23,8 @@
|
||||
*/
|
||||
|
||||
use SP\Account\AccountUtil;
|
||||
use SP\Config\Config;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\DataModel\FileData;
|
||||
use SP\Html\Html;
|
||||
@@ -35,16 +33,15 @@ use SP\Http\Response;
|
||||
use SP\Log\Log;
|
||||
use SP\Mgmt\Files\File;
|
||||
use SP\Mgmt\Files\FileUtil;
|
||||
use SP\Util\Checks;
|
||||
use SP\Util\Util;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
if (!Init::isLoggedIn()) {
|
||||
if (!Util::isLoggedIn($dic->get(\SP\Core\SessionFactory::class))) {
|
||||
Util::logout();
|
||||
}
|
||||
|
||||
@@ -54,7 +51,10 @@ if (!$sk || !SessionUtil::checkSessionKey($sk)) {
|
||||
Response::printJson(__('CONSULTA INVÁLIDA'));
|
||||
}
|
||||
|
||||
if (!Checks::fileIsEnabled()) {
|
||||
/** @var \SP\Config\ConfigData $ConfigData */
|
||||
$ConfigData = $dic->get(\SP\Config\ConfigData::class);
|
||||
|
||||
if (!$ConfigData->isFilesEnabled()) {
|
||||
Response::printJson(__('Gestión de archivos deshabilitada'));
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ if ($actionId === ActionsInterface::ACTION_ACC_FILES_UPLOAD) {
|
||||
|
||||
$LogMessage->setAction(__('Subir Archivo', false));
|
||||
|
||||
$allowedExts = Config::getConfig()->getFilesAllowedExts();
|
||||
$allowedSize = Config::getConfig()->getFilesAllowedSize();
|
||||
$allowedExts = $ConfigData->getFilesAllowedExts();
|
||||
$allowedSize = $ConfigData->getFilesAllowedSize();
|
||||
|
||||
if (count($allowedExts) === 0) {
|
||||
$LogMessage->addDescription(__('No hay extensiones permitidas', false));
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -22,7 +22,6 @@
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\Controller\AccountController;
|
||||
use SP\Controller\AccountSearchController;
|
||||
use SP\Controller\ConfigController;
|
||||
@@ -31,9 +30,7 @@ use SP\Controller\ItemListController;
|
||||
use SP\Controller\NoticesController;
|
||||
use SP\Controller\UserPreferencesController;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\DiFactory;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\SessionFactory;
|
||||
use SP\Core\Template;
|
||||
use SP\Http\Request;
|
||||
use SP\Http\Response;
|
||||
@@ -41,11 +38,18 @@ use SP\Util\Util;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
if (!Init::isLoggedIn()) {
|
||||
/** @var \SP\Storage\Database $db */
|
||||
$db = $dic->get(\SP\Storage\Database::class);
|
||||
/** @var SessionFactory $session */
|
||||
$session = $dic->get(SessionFactory::class);
|
||||
/** @var \SP\Core\UI\Theme $theme */
|
||||
$theme = $dic->get(\SP\Core\UI\Theme::class);
|
||||
|
||||
if (!Util::isLoggedIn($session)) {
|
||||
Util::logout();
|
||||
}
|
||||
|
||||
@@ -58,7 +62,7 @@ if (!Request::analyze('actionId', 0, true)) {
|
||||
$actionId = Request::analyze('actionId', 0);
|
||||
$itemId = Request::analyze('itemId', 0);
|
||||
|
||||
$UserData = Session::getUserData();
|
||||
$UserData = SessionFactory::getUserData();
|
||||
|
||||
$Tpl = new Template();
|
||||
$Tpl->assign('actionId', $actionId);
|
||||
@@ -69,7 +73,7 @@ $Tpl->assign('userId', $UserData->getUserId());
|
||||
$Tpl->assign('userGroupId', $UserData->getUserGroupId());
|
||||
$Tpl->assign('userIsAdminApp', $UserData->isUserIsAdminApp());
|
||||
$Tpl->assign('userIsAdminAcc', $UserData->isUserIsAdminAcc());
|
||||
$Tpl->assign('themeUri', DiFactory::getTheme()->getThemeUri());
|
||||
$Tpl->assign('themeUri', $theme->getThemeUri());
|
||||
|
||||
switch ($actionId) {
|
||||
case ActionsInterface::ACTION_ACC_SEARCH:
|
||||
@@ -136,8 +140,11 @@ switch ($actionId) {
|
||||
break;
|
||||
}
|
||||
|
||||
/** @var \SP\Config\ConfigData $ConfigData */
|
||||
$ConfigData = $dic->get(\SP\Config\ConfigData::class);
|
||||
|
||||
// Se comprueba si se debe de mostrar la vista de depuración
|
||||
if ($UserData->isUserIsAdminApp() && Config::getConfig()->isDebug()) {
|
||||
if ($UserData->isUserIsAdminApp() && $ConfigData->isDebug()) {
|
||||
$Controller->getDebug();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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/>.
|
||||
*/
|
||||
|
||||
use SP\Auth\Browser\Browser;
|
||||
use SP\Config\Config;
|
||||
use SP\Core\CryptPKI;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\Plugin\PluginUtil;
|
||||
use SP\Core\Session;
|
||||
use SP\Http\Cookies;
|
||||
use SP\Http\Request;
|
||||
use SP\Http\Response;
|
||||
use SP\Util\Checks;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'strings.js.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
$Config = Config::getConfig();
|
||||
|
||||
$data = [
|
||||
'lang' => $stringsJsLang,
|
||||
'locale' => $Config->getSiteLang(),
|
||||
'app_root' => Init::$WEBURI,
|
||||
'pk' => '',
|
||||
'max_file_size' => $Config->getFilesAllowedSize(),
|
||||
'check_updates' => Session::getAuthCompleted() && ($Config->isCheckUpdates() || $Config->isChecknotices()) && (Session::getUserData()->isUserIsAdminApp() || Checks::demoIsEnabled()),
|
||||
'timezone' => date_default_timezone_get(),
|
||||
'debug' => DEBUG || $Config->isDebug(),
|
||||
'cookies_enabled' => Cookies::checkCookies(),
|
||||
'plugins' => PluginUtil::getEnabledPlugins(),
|
||||
'loggedin' => Init::isLoggedIn(),
|
||||
'authbasic_autologin' => Browser::getServerAuthUser() && Config::getConfig()->isAuthBasicAutoLoginEnabled()
|
||||
];
|
||||
|
||||
try {
|
||||
$CryptPKI = new CryptPKI();
|
||||
$data['pk'] = Session::getPublicKey() ?: $CryptPKI->getPublicKey();
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
Response::printJson($data, 0);
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ use SP\Util\Json;
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
define('IS_INSTALLER', 1);
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ use SP\Util\Json;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
session_write_close();
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ use SP\Http\Request;
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
define('IS_UPGRADE', 1);
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ use Plugins\Authenticator\Authenticator;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\Language;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\SessionFactory;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\DiFactory;
|
||||
use SP\Http\JsonResponse;
|
||||
@@ -40,13 +40,20 @@ use SP\Util\Util;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('POST');
|
||||
|
||||
$Json = new JsonResponse();
|
||||
|
||||
if (!Init::isLoggedIn()) {
|
||||
/** @var \SP\Storage\Database $db */
|
||||
$db = $dic->get(\SP\Storage\Database::class);
|
||||
/** @var SessionFactory $session */
|
||||
$session = $dic->get(SessionFactory::class);
|
||||
/** @var \SP\Core\UI\Theme $theme */
|
||||
$theme = $dic->get(\SP\Core\UI\Theme::class);
|
||||
|
||||
if (!Util::isLoggedIn($session)) {
|
||||
$Json->setStatus(10);
|
||||
$Json->setDescription(__('La sesión no se ha iniciado o ha caducado'));
|
||||
Json::returnJson($Json);
|
||||
@@ -80,10 +87,10 @@ if ($actionId === ActionsInterface::ACTION_USR_PREFERENCES_GENERAL) {
|
||||
UserPreferences::getItem($UserPreferencesData)->update();
|
||||
// Forzar la detección del lenguaje tras actualizar
|
||||
Language::setLanguage(true);
|
||||
DiFactory::getTheme()->initTheme(true);
|
||||
$theme->initTheme(true);
|
||||
|
||||
// Actualizar las preferencias en la sesión y recargar la página
|
||||
Session::setUserPreferences($UserPreferencesData);
|
||||
SessionFactory::setUserPreferences($UserPreferencesData);
|
||||
Util::reload();
|
||||
|
||||
$Json->setStatus(0);
|
||||
|
||||
@@ -27,7 +27,7 @@ use SP\Http\Request;
|
||||
|
||||
define('APP_ROOT', dirname(__DIR__));
|
||||
|
||||
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
Request::checkReferer('GET');
|
||||
|
||||
|
||||
2
api.php
2
api.php
@@ -27,7 +27,7 @@ use SP\Log\Log;
|
||||
|
||||
define('APP_ROOT', '.');
|
||||
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
require APP_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Base.php';
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
|
||||
0
config/.blank → app/cache/.blank
vendored
0
config/.blank → app/cache/.blank
vendored
47
app/config/config.php
Normal file
47
app/config/config.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// Generated on 1453548115
|
||||
// This file is generated automatically on installation process
|
||||
// Please, modify with caution, it could break the application
|
||||
$CONFIG = array (
|
||||
'account_count' => 12,
|
||||
'account_link' => 1,
|
||||
'account_passtoimage' => false,
|
||||
'checknotices' => true,
|
||||
'checkupdates' => true,
|
||||
'config_hash' => '53489a9c67140c7a72d12b71cb1eefd5',
|
||||
'dbhost' => 'localhost',
|
||||
'dbname' => 'syspass',
|
||||
'dbpass' => 'ff6555bb87aa43d732346d2224736095',
|
||||
'dbuser' => 'sp_admin',
|
||||
'debug' => false,
|
||||
'demo_enabled' => false,
|
||||
'files_allowed_exts' => 'PDF,JPG,GIF,PNG,ODT,ODS,DOC,DOCX,XLS,XSL,VSD,TXT,CSV,BAK',
|
||||
'files_allowed_size' => 1024,
|
||||
'files_enabled' => true,
|
||||
'globalsearch' => false,
|
||||
'installed' => 1,
|
||||
'ldap_base' => '',
|
||||
'ldap_enabled' => false,
|
||||
'ldap_group' => '',
|
||||
'ldap_server' => '',
|
||||
'ldap_userattr' => '',
|
||||
'log_enabled' => true,
|
||||
'mail_enabled' => false,
|
||||
'mail_from' => '',
|
||||
'mail_server' => '',
|
||||
'passwordsalt' => 'b6417b24176faa7d6543dc05874ca6',
|
||||
'proxy_enabled' => false,
|
||||
'proxy_pass' => '',
|
||||
'proxy_port' => '',
|
||||
'proxy_server' => '',
|
||||
'proxy_user' => '',
|
||||
'resultsascards' => false,
|
||||
'session_timeout' => '300',
|
||||
'site_lang' => '',
|
||||
'sitetheme' => 'material-blue',
|
||||
'version' => '1316011001',
|
||||
'wiki_enabled' => false,
|
||||
'wiki_filter' => '',
|
||||
'wiki_pageurl' => '',
|
||||
'wiki_searchurl' => '',
|
||||
);
|
||||
47
app/config/config.php.old
Normal file
47
app/config/config.php.old
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// Generated on 1453548115
|
||||
// This file is generated automatically on installation process
|
||||
// Please, modify with caution, it could break the application
|
||||
$CONFIG = array (
|
||||
'account_count' => 12,
|
||||
'account_link' => 1,
|
||||
'account_passtoimage' => false,
|
||||
'checknotices' => true,
|
||||
'checkupdates' => true,
|
||||
'config_hash' => '53489a9c67140c7a72d12b71cb1eefd5',
|
||||
'dbhost' => 'localhost',
|
||||
'dbname' => 'syspass',
|
||||
'dbpass' => 'ff6555bb87aa43d732346d2224736095',
|
||||
'dbuser' => 'sp_admin',
|
||||
'debug' => false,
|
||||
'demo_enabled' => false,
|
||||
'files_allowed_exts' => 'PDF,JPG,GIF,PNG,ODT,ODS,DOC,DOCX,XLS,XSL,VSD,TXT,CSV,BAK',
|
||||
'files_allowed_size' => 1024,
|
||||
'files_enabled' => true,
|
||||
'globalsearch' => false,
|
||||
'installed' => 1,
|
||||
'ldap_base' => '',
|
||||
'ldap_enabled' => false,
|
||||
'ldap_group' => '',
|
||||
'ldap_server' => '',
|
||||
'ldap_userattr' => '',
|
||||
'log_enabled' => true,
|
||||
'mail_enabled' => false,
|
||||
'mail_from' => '',
|
||||
'mail_server' => '',
|
||||
'passwordsalt' => 'b6417b24176faa7d6543dc05874ca6',
|
||||
'proxy_enabled' => false,
|
||||
'proxy_pass' => '',
|
||||
'proxy_port' => '',
|
||||
'proxy_server' => '',
|
||||
'proxy_user' => '',
|
||||
'resultsascards' => false,
|
||||
'session_timeout' => '300',
|
||||
'site_lang' => '',
|
||||
'sitetheme' => 'material-blue',
|
||||
'version' => '1316011001',
|
||||
'wiki_enabled' => false,
|
||||
'wiki_filter' => '',
|
||||
'wiki_pageurl' => '',
|
||||
'wiki_searchurl' => '',
|
||||
);
|
||||
103
app/config/config.xml
Normal file
103
app/config/config.xml
Normal file
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<config>
|
||||
<accountCount>12</accountCount>
|
||||
<accountFullGroupAccess>0</accountFullGroupAccess>
|
||||
<accountLink>1</accountLink>
|
||||
<accountPassToImage>0</accountPassToImage>
|
||||
<authBasicAutoLoginEnabled>1</authBasicAutoLoginEnabled>
|
||||
<authBasicDomain></authBasicDomain>
|
||||
<authBasicEnabled>1</authBasicEnabled>
|
||||
<backup_hash>36294f0e4218f177180b419cf2a853bf765b2f6d</backup_hash>
|
||||
<checkUpdates>1</checkUpdates>
|
||||
<checknotices>0</checknotices>
|
||||
<configDate>1505767472</configDate>
|
||||
<configHash>c49414b14004c75fcd3b6578814941f9</configHash>
|
||||
<configSaver></configSaver>
|
||||
<configVersion>22017050101</configVersion>
|
||||
<dbHost>syspass-db</dbHost>
|
||||
<dbName>syspass</dbName>
|
||||
<dbPass>G0fq^NjmQ2lr:e3o</dbPass>
|
||||
<dbPort>3306</dbPort>
|
||||
<dbSocket></dbSocket>
|
||||
<dbUser>sp_admin</dbUser>
|
||||
<debug>0</debug>
|
||||
<demoEnabled>0</demoEnabled>
|
||||
<dokuwikiEnabled>0</dokuwikiEnabled>
|
||||
<dokuwikiNamespace></dokuwikiNamespace>
|
||||
<dokuwikiPass></dokuwikiPass>
|
||||
<dokuwikiUrl></dokuwikiUrl>
|
||||
<dokuwikiUrlBase></dokuwikiUrlBase>
|
||||
<dokuwikiUser></dokuwikiUser>
|
||||
<encryptSession>0</encryptSession>
|
||||
<export_hash>300049b78c19e759bc589f9a56dbb6473bf7cc9c</export_hash>
|
||||
<filesAllowedExts>
|
||||
<item type="filesAllowedExts">PDF</item>
|
||||
<item type="filesAllowedExts">JPG</item>
|
||||
<item type="filesAllowedExts">GIF</item>
|
||||
<item type="filesAllowedExts">PNG</item>
|
||||
<item type="filesAllowedExts">ODT</item>
|
||||
<item type="filesAllowedExts">ODS</item>
|
||||
<item type="filesAllowedExts">DOC</item>
|
||||
<item type="filesAllowedExts">DOCX</item>
|
||||
<item type="filesAllowedExts">XLS</item>
|
||||
<item type="filesAllowedExts">XSL</item>
|
||||
<item type="filesAllowedExts">VSD</item>
|
||||
<item type="filesAllowedExts">TXT</item>
|
||||
<item type="filesAllowedExts">CSV</item>
|
||||
<item type="filesAllowedExts">BAK</item>
|
||||
<item type="filesAllowedExts">RDP</item>
|
||||
<item type="filesAllowedExts">KEY</item>
|
||||
</filesAllowedExts>
|
||||
<filesAllowedSize>1024</filesAllowedSize>
|
||||
<filesEnabled>1</filesEnabled>
|
||||
<globalSearch>1</globalSearch>
|
||||
<httpsEnabled>0</httpsEnabled>
|
||||
<installed>1</installed>
|
||||
<ldapAds>0</ldapAds>
|
||||
<ldapBase>dc=demo1,dc=freeipa,dc=org</ldapBase>
|
||||
<ldapBindPass>Secret123</ldapBindPass>
|
||||
<ldapBindUser>uid=admin,cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org</ldapBindUser>
|
||||
<ldapDefaultGroup>1</ldapDefaultGroup>
|
||||
<ldapDefaultProfile>1</ldapDefaultProfile>
|
||||
<ldapEnabled>0</ldapEnabled>
|
||||
<ldapGroup></ldapGroup>
|
||||
<ldapProxyUser></ldapProxyUser>
|
||||
<ldapServer>ipa.demo1.freeipa.org</ldapServer>
|
||||
<ldapUserattr></ldapUserattr>
|
||||
<logEnabled>1</logEnabled>
|
||||
<mailAuthenabled>1</mailAuthenabled>
|
||||
<mailEnabled>1</mailEnabled>
|
||||
<mailFrom>test@syspass.org</mailFrom>
|
||||
<mailPass>&J$wkt+1QheO</mailPass>
|
||||
<mailPort>25</mailPort>
|
||||
<mailRequestsEnabled>0</mailRequestsEnabled>
|
||||
<mailSecurity></mailSecurity>
|
||||
<mailServer>mail.syspass.org</mailServer>
|
||||
<mailUser>test@syspass.org</mailUser>
|
||||
<maintenance>0</maintenance>
|
||||
<passwordSalt>fcc85b56f961971ed30b2ca0073e9fde4fd2e7c893106da2963a5a2b5dcb</passwordSalt>
|
||||
<proxyEnabled>0</proxyEnabled>
|
||||
<proxyPass></proxyPass>
|
||||
<proxyPort>8080</proxyPort>
|
||||
<proxyServer></proxyServer>
|
||||
<proxyUser></proxyUser>
|
||||
<publinksEnabled>0</publinksEnabled>
|
||||
<publinksImageEnabled>0</publinksImageEnabled>
|
||||
<publinksMaxTime>600</publinksMaxTime>
|
||||
<publinksMaxViews>3</publinksMaxViews>
|
||||
<resultsAsCards>0</resultsAsCards>
|
||||
<sessionTimeout>900</sessionTimeout>
|
||||
<siteLang>en_US</siteLang>
|
||||
<siteTheme>material-blue</siteTheme>
|
||||
<ssoDefaultGroup>0</ssoDefaultGroup>
|
||||
<ssoDefaultProfile>0</ssoDefaultProfile>
|
||||
<syslogEnabled>0</syslogEnabled>
|
||||
<syslogPort>514</syslogPort>
|
||||
<syslogRemoteEnabled>0</syslogRemoteEnabled>
|
||||
<syslogServer></syslogServer>
|
||||
<upgradeKey></upgradeKey>
|
||||
<wikiEnabled>0</wikiEnabled>
|
||||
<wikiFilter></wikiFilter>
|
||||
<wikiPageurl></wikiPageurl>
|
||||
<wikiSearchurl></wikiSearchurl>
|
||||
</config>
|
||||
103
app/config/config.xml.orig
Normal file
103
app/config/config.xml.orig
Normal file
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<config>
|
||||
<accountCount>12</accountCount>
|
||||
<accountFullGroupAccess>0</accountFullGroupAccess>
|
||||
<accountLink>1</accountLink>
|
||||
<accountPassToImage>0</accountPassToImage>
|
||||
<authBasicAutoLoginEnabled>1</authBasicAutoLoginEnabled>
|
||||
<authBasicDomain></authBasicDomain>
|
||||
<authBasicEnabled>1</authBasicEnabled>
|
||||
<backup_hash>36294f0e4218f177180b419cf2a853bf765b2f6d</backup_hash>
|
||||
<checkUpdates>1</checkUpdates>
|
||||
<checknotices>0</checknotices>
|
||||
<configDate>1505767472</configDate>
|
||||
<configHash>c49414b14004c75fcd3b6578814941f9</configHash>
|
||||
<configSaver></configSaver>
|
||||
<configVersion>22017050101</configVersion>
|
||||
<dbHost>syspass-db</dbHost>
|
||||
<dbName>syspass</dbName>
|
||||
<dbPass>G0fq^NjmQ2lr:e3o</dbPass>
|
||||
<dbPort>3306</dbPort>
|
||||
<dbSocket></dbSocket>
|
||||
<dbUser>sp_admin</dbUser>
|
||||
<debug>0</debug>
|
||||
<demoEnabled>0</demoEnabled>
|
||||
<dokuwikiEnabled>0</dokuwikiEnabled>
|
||||
<dokuwikiNamespace></dokuwikiNamespace>
|
||||
<dokuwikiPass></dokuwikiPass>
|
||||
<dokuwikiUrl></dokuwikiUrl>
|
||||
<dokuwikiUrlBase></dokuwikiUrlBase>
|
||||
<dokuwikiUser></dokuwikiUser>
|
||||
<encryptSession>0</encryptSession>
|
||||
<export_hash>300049b78c19e759bc589f9a56dbb6473bf7cc9c</export_hash>
|
||||
<filesAllowedExts>
|
||||
<item type="filesAllowedExts">PDF</item>
|
||||
<item type="filesAllowedExts">JPG</item>
|
||||
<item type="filesAllowedExts">GIF</item>
|
||||
<item type="filesAllowedExts">PNG</item>
|
||||
<item type="filesAllowedExts">ODT</item>
|
||||
<item type="filesAllowedExts">ODS</item>
|
||||
<item type="filesAllowedExts">DOC</item>
|
||||
<item type="filesAllowedExts">DOCX</item>
|
||||
<item type="filesAllowedExts">XLS</item>
|
||||
<item type="filesAllowedExts">XSL</item>
|
||||
<item type="filesAllowedExts">VSD</item>
|
||||
<item type="filesAllowedExts">TXT</item>
|
||||
<item type="filesAllowedExts">CSV</item>
|
||||
<item type="filesAllowedExts">BAK</item>
|
||||
<item type="filesAllowedExts">RDP</item>
|
||||
<item type="filesAllowedExts">KEY</item>
|
||||
</filesAllowedExts>
|
||||
<filesAllowedSize>1024</filesAllowedSize>
|
||||
<filesEnabled>1</filesEnabled>
|
||||
<globalSearch>1</globalSearch>
|
||||
<httpsEnabled>0</httpsEnabled>
|
||||
<installed>1</installed>
|
||||
<ldapAds>0</ldapAds>
|
||||
<ldapBase>dc=demo1,dc=freeipa,dc=org</ldapBase>
|
||||
<ldapBindPass>Secret123</ldapBindPass>
|
||||
<ldapBindUser>uid=admin,cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org</ldapBindUser>
|
||||
<ldapDefaultGroup>1</ldapDefaultGroup>
|
||||
<ldapDefaultProfile>1</ldapDefaultProfile>
|
||||
<ldapEnabled>0</ldapEnabled>
|
||||
<ldapGroup></ldapGroup>
|
||||
<ldapProxyUser></ldapProxyUser>
|
||||
<ldapServer>ipa.demo1.freeipa.org</ldapServer>
|
||||
<ldapUserattr></ldapUserattr>
|
||||
<logEnabled>1</logEnabled>
|
||||
<mailAuthenabled>1</mailAuthenabled>
|
||||
<mailEnabled>1</mailEnabled>
|
||||
<mailFrom>test@syspass.org</mailFrom>
|
||||
<mailPass>&J$wkt+1QheO</mailPass>
|
||||
<mailPort>25</mailPort>
|
||||
<mailRequestsEnabled>0</mailRequestsEnabled>
|
||||
<mailSecurity></mailSecurity>
|
||||
<mailServer>mail.syspass.org</mailServer>
|
||||
<mailUser>test@syspass.org</mailUser>
|
||||
<maintenance>0</maintenance>
|
||||
<passwordSalt>fcc85b56f961971ed30b2ca0073e9fde4fd2e7c893106da2963a5a2b5dcb</passwordSalt>
|
||||
<proxyEnabled>0</proxyEnabled>
|
||||
<proxyPass></proxyPass>
|
||||
<proxyPort>8080</proxyPort>
|
||||
<proxyServer></proxyServer>
|
||||
<proxyUser></proxyUser>
|
||||
<publinksEnabled>0</publinksEnabled>
|
||||
<publinksImageEnabled>0</publinksImageEnabled>
|
||||
<publinksMaxTime>600</publinksMaxTime>
|
||||
<publinksMaxViews>3</publinksMaxViews>
|
||||
<resultsAsCards>0</resultsAsCards>
|
||||
<sessionTimeout>900</sessionTimeout>
|
||||
<siteLang>en_US</siteLang>
|
||||
<siteTheme>material-blue</siteTheme>
|
||||
<ssoDefaultGroup>0</ssoDefaultGroup>
|
||||
<ssoDefaultProfile>0</ssoDefaultProfile>
|
||||
<syslogEnabled>0</syslogEnabled>
|
||||
<syslogPort>514</syslogPort>
|
||||
<syslogRemoteEnabled>0</syslogRemoteEnabled>
|
||||
<syslogServer></syslogServer>
|
||||
<upgradeKey></upgradeKey>
|
||||
<wikiEnabled>0</wikiEnabled>
|
||||
<wikiFilter></wikiFilter>
|
||||
<wikiPageurl></wikiPageurl>
|
||||
<wikiSearchurl></wikiSearchurl>
|
||||
</config>
|
||||
6
app/config/pubkey.pem
Normal file
6
app/config/pubkey.pem
Normal file
@@ -0,0 +1,6 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCm3GrBV/VrnCzpClpnXKrh2P0J
|
||||
AY/DMf4h5bzod0G5UciVQVBZiXyjeIM4mNawkJZ94sl5KjmznmBYy7fXL1Bpvsjz
|
||||
hnegpbBo0rgJKrHXhnTzVSyMiCW03BUyBYosjex6ZNZTmyuvyrBiW+nWKEAuDqby
|
||||
z6TAMF9Z4TBiZE9mqQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
373
app/modules/web/Controllers/AccountController.php
Normal file
373
app/modules/web/Controllers/AccountController.php
Normal file
@@ -0,0 +1,373 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers;
|
||||
|
||||
use SP\Controller\ControllerBase;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Http\Request;
|
||||
use SP\Http\Response;
|
||||
use SP\Mgmt\Files\FileUtil;
|
||||
use SP\Modules\Web\Controllers\Helpers\AccountHelper;
|
||||
use SP\Modules\Web\Controllers\Helpers\AccountSearchHelper;
|
||||
use SP\Mvc\Controller\CrudControllerInterface;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers
|
||||
*/
|
||||
class AccountController extends ControllerBase implements CrudControllerInterface
|
||||
{
|
||||
/**
|
||||
* Index action
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
try {
|
||||
$AccountSearchHelper = new AccountSearchHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountSearchHelper->getSearchBox();
|
||||
$AccountSearchHelper->getSearch();
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.search', $this);
|
||||
|
||||
$this->view();
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search action
|
||||
*/
|
||||
public function searchAction()
|
||||
{
|
||||
try {
|
||||
$AccountSearchHelper = new AccountSearchHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountSearchHelper->getSearch();
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.search', $this);
|
||||
|
||||
$data = [
|
||||
'sk' => SessionUtil::getSessionKey(),
|
||||
'html' => $this->render()
|
||||
];
|
||||
|
||||
Response::printJson($data, 0);
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View action
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public function viewAction($id)
|
||||
{
|
||||
try {
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccountData($id, ActionsInterface::ACTION_ACC_VIEW);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess($this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('account');
|
||||
$this->view->assign('title',
|
||||
[
|
||||
'class' => 'titleNormal',
|
||||
'name' => __('Detalles de Cuenta'),
|
||||
'icon' => $this->icons->getIconView()->getIcon()
|
||||
]
|
||||
);
|
||||
|
||||
$this->view->assign('isView', true);
|
||||
|
||||
$AccountHelper->getAccount()->incrementViewCounter();
|
||||
$AccountHelper->setCommonData();
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.view', $this);
|
||||
|
||||
$this->view();
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la vista de archivos de una cuenta
|
||||
*
|
||||
* @param int $id
|
||||
* @return bool|void
|
||||
*/
|
||||
public function listFilesAction($id)
|
||||
{
|
||||
if (!$this->configData->isFilesEnabled()) {
|
||||
die(__('Gestión de archivos deshabilitada'));
|
||||
}
|
||||
|
||||
try {
|
||||
$this->setAction(ActionsInterface::ACTION_ACC_FILES);
|
||||
|
||||
$this->view->addTemplate('files-list', 'account');
|
||||
|
||||
$this->view->assign('accountId', $id);
|
||||
$this->view->assign('deleteEnabled', Request::analyze('del', 0));
|
||||
$this->view->assign('files', FileUtil::getAccountFiles($id));
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
|
||||
if (!is_array($this->view->files) || count($this->view->files) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.listfiles', $this);
|
||||
|
||||
$this->view();
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create action
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
try {
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setActionId(ActionsInterface::ACTION_ACC_NEW);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess($this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('account');
|
||||
$this->view->assign('title',
|
||||
[
|
||||
'class' => 'titleGreen',
|
||||
'name' => __('Nueva Cuenta'),
|
||||
'icon' => $this->icons->getIconAdd()->getIcon()
|
||||
]
|
||||
);
|
||||
|
||||
// SessionFactory::setLastAcountId(0);
|
||||
$AccountHelper->setCommonData();
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.new', $this);
|
||||
|
||||
$this->view();
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit action
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public function editAction($id)
|
||||
{
|
||||
try {
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccountData($id, ActionsInterface::ACTION_ACC_EDIT);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess($this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('account');
|
||||
$this->view->assign('title',
|
||||
[
|
||||
'class' => 'titleOrange',
|
||||
'name' => __('Editar Cuenta'),
|
||||
'icon' => $this->icons->getIconEdit()->getIcon()
|
||||
]
|
||||
);
|
||||
|
||||
$AccountHelper->getAccount()->incrementViewCounter();
|
||||
$AccountHelper->setCommonData();
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.edit', $this);
|
||||
|
||||
$this->view();
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save or modify action
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public function saveAction($id)
|
||||
{
|
||||
// TODO: Implement saveAction() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete action
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public function deleteAction($id)
|
||||
{
|
||||
try {
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccountData($id, ActionsInterface::ACTION_ACC_DELETE);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess($this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('account');
|
||||
$this->view->assign('title',
|
||||
[
|
||||
'class' => 'titleRed',
|
||||
'name' => __('Eliminar Cuenta'),
|
||||
'icon' => $this->icons->getIconDelete()->getIcon()
|
||||
]
|
||||
);
|
||||
|
||||
$AccountHelper->setCommonData();
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.delete', $this);
|
||||
|
||||
$this->view();
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para mostrar el interface para modificar la clave de cuenta
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public function editPassAction($id)
|
||||
{
|
||||
try {
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccountData($id, ActionsInterface::ACTION_ACC_EDIT_PASS);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess($this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('account-editpass');
|
||||
$this->view->assign('title',
|
||||
[
|
||||
'class' => 'titleOrange',
|
||||
'name' => __('Modificar Clave de Cuenta'),
|
||||
'icon' => $this->icons->getIconEditPass()->getIcon()
|
||||
]
|
||||
);
|
||||
|
||||
$this->view->assign('accountPassDateChange', gmdate('Y-m-d', $AccountHelper->getAccount()->getAccountData()->getAccountPassDateChange()));
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.editpass', $this);
|
||||
|
||||
$this->view();
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para mostrar el interface para ver cuenta en fecha concreta
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public function viewHistoryAction($id)
|
||||
{
|
||||
try {
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccountDataHistory($id, ActionsInterface::ACTION_ACC_VIEW_HISTORY);
|
||||
|
||||
// Obtener los datos de la cuenta antes y comprobar el acceso
|
||||
if (!$AccountHelper->checkAccess($this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('account');
|
||||
$this->view->assign('title',
|
||||
[
|
||||
'class' => 'titleNormal',
|
||||
'name' => __('Detalles de Cuenta'),
|
||||
'icon' => 'access_time'
|
||||
]
|
||||
);
|
||||
|
||||
$this->view->assign('isView', true);
|
||||
$AccountHelper->getAccount()->setAccountIsHistory(1);
|
||||
|
||||
$AccountHelper->setCommonData();
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.viewhistory', $this);
|
||||
|
||||
$this->view();
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para mostrar el interface de solicitud de cambios en una cuenta
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public function requestAccessAction($id)
|
||||
{
|
||||
try {
|
||||
$AccountHelper = new AccountHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$AccountHelper->setAccountDataHistory($id, ActionsInterface::ACTION_ACC_REQUEST);
|
||||
|
||||
$this->view->addTemplate('request');
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.request', $this);
|
||||
|
||||
$this->view();
|
||||
} catch (SPException $e) {
|
||||
$this->showError(self::ERR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize class
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->checkLoggedIn();
|
||||
}
|
||||
}
|
||||
75
app/modules/web/Controllers/BootstrapController.php
Normal file
75
app/modules/web/Controllers/BootstrapController.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers;
|
||||
|
||||
use Exception;
|
||||
use SP\Auth\Browser\Browser;
|
||||
use SP\Bootstrap;
|
||||
use SP\Core\CryptPKI;
|
||||
use SP\Core\Plugin\PluginUtil;
|
||||
use SP\Core\SessionFactory;
|
||||
use SP\Http\Cookies;
|
||||
use SP\Http\Response;
|
||||
|
||||
/**
|
||||
* Class BootstrapController
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers
|
||||
*/
|
||||
class BootstrapController extends SimpleControllerBase
|
||||
{
|
||||
/**
|
||||
* Returns environment data
|
||||
*/
|
||||
public function getEnvironmentAction()
|
||||
{
|
||||
$configData = $this->config->getConfigData();
|
||||
|
||||
$data = [
|
||||
'lang' => require PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'strings.js.php',
|
||||
'locale' => $configData->getSiteLang(),
|
||||
'app_root' => Bootstrap::$WEBURI,
|
||||
'pk' => '',
|
||||
'max_file_size' => $configData->getFilesAllowedSize(),
|
||||
'check_updates' => $this->session->getAuthCompleted()
|
||||
&& ($configData->isCheckUpdates() || $configData->isChecknotices())
|
||||
&& ($this->session->getUserData()->isUserIsAdminApp() || $configData->isDemoEnabled()),
|
||||
'timezone' => date_default_timezone_get(),
|
||||
'debug' => DEBUG || $configData->isDebug(),
|
||||
'cookies_enabled' => Cookies::checkCookies(),
|
||||
'plugins' => PluginUtil::getEnabledPlugins(),
|
||||
'loggedin' => $this->session->isLoggedIn(),
|
||||
'authbasic_autologin' => Browser::getServerAuthUser() && $configData->isAuthBasicAutoLoginEnabled()
|
||||
];
|
||||
|
||||
try {
|
||||
$CryptPKI = new CryptPKI();
|
||||
$data['pk'] = SessionFactory::getPublicKey() ?: $CryptPKI->getPublicKey();
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
Response::printJson($data, 0);
|
||||
}
|
||||
}
|
||||
288
app/modules/web/Controllers/Helpers/AccountHelper.php
Normal file
288
app/modules/web/Controllers/Helpers/AccountHelper.php
Normal file
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers\Helpers;
|
||||
|
||||
use SP\Account\Account;
|
||||
use SP\Account\AccountAcl;
|
||||
use SP\Account\AccountHistory;
|
||||
use SP\Account\AccountUtil;
|
||||
use SP\Account\UserAccounts;
|
||||
use SP\Controller\ControllerBase;
|
||||
use SP\Core\Acl;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Init;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\DataModel\AccountExtData;
|
||||
use SP\DataModel\CustomFieldData;
|
||||
use SP\Mgmt\Categories\Category;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\Groups\Group;
|
||||
use SP\Mgmt\Groups\GroupAccountsUtil;
|
||||
use SP\Mgmt\PublicLinks\PublicLink;
|
||||
use SP\Mgmt\Tags\Tag;
|
||||
use SP\Mgmt\Users\UserPass;
|
||||
use SP\Mgmt\Users\UserUtil;
|
||||
use SP\Util\Json;
|
||||
|
||||
/**
|
||||
* Class AccountHelper
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers\Helpers
|
||||
*/
|
||||
class AccountHelper extends HelperBase
|
||||
{
|
||||
/** @var Acl */
|
||||
protected $acl;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $actionId;
|
||||
/**
|
||||
* @var AccountAcl
|
||||
*/
|
||||
private $AccountAcl;
|
||||
/**
|
||||
* @var Account|AccountHistory instancia para el manejo de datos de una cuenta
|
||||
*/
|
||||
private $Account;
|
||||
/**
|
||||
* @var int con el id de la cuenta
|
||||
*/
|
||||
private $id;
|
||||
/**
|
||||
* @var AccountExtData
|
||||
*/
|
||||
private $AccountData;
|
||||
|
||||
/**
|
||||
* @param Acl $acl
|
||||
*/
|
||||
public function inject(Acl $acl)
|
||||
{
|
||||
$this->acl = $acl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer las variables que contienen la información de la cuenta.
|
||||
*
|
||||
* @param $accountId
|
||||
* @param $actionId
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function setAccountData($accountId, $actionId)
|
||||
{
|
||||
$this->id = $accountId;
|
||||
$this->actionId = $actionId;
|
||||
|
||||
$Account = new Account(new AccountExtData($accountId));
|
||||
$this->Account = $Account;
|
||||
$this->AccountData = $Account->getData();
|
||||
|
||||
$this->view->assign('accountId', $this->id);
|
||||
$this->view->assign('accountData', $this->AccountData);
|
||||
$this->view->assign('gotData', $this->isGotData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
private function isGotData()
|
||||
{
|
||||
return $this->AccountData !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer las variables que contienen la información de la cuenta en una fecha concreta.
|
||||
*
|
||||
* @param $accountId
|
||||
* @param $actionId
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function setAccountDataHistory($accountId, $actionId)
|
||||
{
|
||||
$this->id = $accountId;
|
||||
$this->actionId = $actionId;
|
||||
|
||||
$Account = new AccountHistory(new AccountExtData());
|
||||
$Account->setId($accountId);
|
||||
$this->Account = $Account;
|
||||
$this->AccountData = $Account->getData();
|
||||
|
||||
$this->view->assign('accountId', $this->AccountData->getAccountId());
|
||||
$this->view->assign('accountData', $this->AccountData);
|
||||
$this->view->assign('gotData', $this->isGotData());
|
||||
$this->view->assign('accountHistoryId', $accountId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccountAcl
|
||||
*/
|
||||
public function getAccountAcl()
|
||||
{
|
||||
return $this->AccountAcl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer variables comunes del formulario para todos los interfaces
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function setCommonData()
|
||||
{
|
||||
$userProfileData = $this->session->getUserProfile();
|
||||
|
||||
$this->getCustomFieldsForItem();
|
||||
|
||||
if ($this->isGotData()) {
|
||||
$this->view->assign('accountIsHistory', $this->getAccount()->getAccountIsHistory());
|
||||
$this->view->assign('accountOtherUsers', UserAccounts::getUsersInfoForAccount($this->id));
|
||||
$this->view->assign('accountOtherGroups', GroupAccountsUtil::getGroupsInfoForAccount($this->id));
|
||||
$this->view->assign('accountTagsJson', Json::getJson(array_keys($this->getAccount()->getAccountData()->getTags())));
|
||||
$this->view->assign('historyData', AccountHistory::getAccountList($this->AccountData->getAccountId()));
|
||||
$this->view->assign('isModified', strtotime($this->AccountData->getAccountDateEdit()) !== false);
|
||||
$this->view->assign('maxFileSize', round($this->configData->getFilesAllowedSize() / 1024, 1));
|
||||
$this->view->assign('filesAllowedExts', implode(',', $this->configData->getFilesAllowedExts()));
|
||||
|
||||
$PublicLinkData = PublicLink::getItem()->getHashForItem($this->id);
|
||||
|
||||
$publicLinkUrl = ($this->configData->isPublinksEnabled() && $PublicLinkData ? Init::$WEBURI . '/index.php?h=' . $PublicLinkData->getPublicLinkHash() . '&a=link' : null);
|
||||
$this->view->assign('publicLinkUrl', $publicLinkUrl);
|
||||
$this->view->assign('publicLinkId', $PublicLinkData ? $PublicLinkData->getPublicLinkId() : 0);
|
||||
|
||||
$this->view->assign('accountPassDate', date('Y-m-d H:i:s', $this->AccountData->getAccountPassDate()));
|
||||
$this->view->assign('accountPassDateChange', date('Y-m-d', $this->AccountData->getAccountPassDateChange() ?: 0));
|
||||
} else {
|
||||
$this->view->assign('accountPassDateChange', date('Y-m-d', time() + 7776000));
|
||||
}
|
||||
|
||||
$this->view->assign('actionId', Acl::getActionRoute($this->actionId));
|
||||
$this->view->assign('categories', Category::getItem()->getItemsForSelect());
|
||||
$this->view->assign('customers', Customer::getItem()->getItemsForSelectByUser());
|
||||
$this->view->assign('otherUsers', UserUtil::getUsersLogin());
|
||||
$this->view->assign('otherUsersJson', Json::getJson($this->view->otherUsers));
|
||||
$this->view->assign('otherGroups', Group::getItem()->getItemsForSelect());
|
||||
$this->view->assign('otherGroupsJson', Json::getJson($this->view->otherGroups));
|
||||
$this->view->assign('tagsJson', Json::getJson(Tag::getItem()->getItemsForSelect()));
|
||||
$this->view->assign('allowPrivate', $userProfileData->isAccPrivate());
|
||||
$this->view->assign('allowPrivateGroup', $userProfileData->isAccPrivateGroup());
|
||||
$this->view->assign('mailRequestEnabled', $this->configData->isMailRequestsEnabled());
|
||||
$this->view->assign('passToImageEnabled', $this->configData->isAccountPassToImage());
|
||||
|
||||
$this->view->assign('otherAccounts', AccountUtil::getAccountsForUser($this->id, $this->session));
|
||||
$this->view->assign('linkedAccounts', AccountUtil::getLinkedAccounts($this->id, $this->session));
|
||||
|
||||
$this->view->assign('addCustomerEnabled', $this->acl->checkUserAccess(ActionsInterface::ACTION_MGM_CUSTOMERS));
|
||||
$this->view->assign('addCategoryEnabled', $this->acl->checkUserAccess(ActionsInterface::ACTION_MGM_CATEGORIES));
|
||||
|
||||
$this->view->assign('disabled', $this->view->isView ? 'disabled' : '');
|
||||
$this->view->assign('readonly', $this->view->isView ? 'readonly' : '');
|
||||
|
||||
$this->view->assign('showViewCustomPass', $this->AccountAcl->isShowViewPass());
|
||||
$this->view->assign('AccountAcl', $this->AccountAcl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener la lista de campos personalizados y sus valores
|
||||
*/
|
||||
private function getCustomFieldsForItem()
|
||||
{
|
||||
$this->view->assign('customFields', CustomField::getItem(new CustomFieldData(ActionsInterface::ACTION_ACC))->getById($this->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \SP\Account\Account|AccountHistory
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->Account ?: new Account(new AccountExtData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si el usuario dispone de acceso al módulo
|
||||
*
|
||||
* @param ControllerBase $controller
|
||||
* @return bool
|
||||
*/
|
||||
public function checkAccess(ControllerBase $controller)
|
||||
{
|
||||
$this->view->assign('showLogo', false);
|
||||
|
||||
$Acl = new AccountAcl($this->Account, $this->actionId);
|
||||
$this->AccountAcl = $Acl;
|
||||
|
||||
if (!$this->acl->checkUserAccess($this->actionId)) {
|
||||
$controller->showError(ControllerBase::ERR_PAGE_NO_PERMISSION);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UserPass::checkUserUpdateMPass($this->session->getUserData()->getUserId())) {
|
||||
$controller->showError(ControllerBase::ERR_UPDATE_MPASS);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->id > 0) {
|
||||
$this->AccountAcl = $Acl->getAcl();
|
||||
|
||||
if (!$this->AccountAcl->checkAccountAccess()) {
|
||||
$controller->showError(ControllerBase::ERR_ACCOUNT_NO_PERMISSION);
|
||||
return false;
|
||||
}
|
||||
|
||||
// SessionFactory::setAccountAcl($this->AccountAcl->save());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionId
|
||||
*/
|
||||
public function setActionId($actionId)
|
||||
{
|
||||
$this->actionId = $actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->view->assign('changesHash');
|
||||
$this->view->assign('chkUserEdit');
|
||||
$this->view->assign('chkGroupEdit');
|
||||
$this->view->assign('gotData', $this->isGotData());
|
||||
$this->view->assign('isView', false);
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
}
|
||||
}
|
||||
383
app/modules/web/Controllers/Helpers/AccountSearchHelper.php
Normal file
383
app/modules/web/Controllers/Helpers/AccountSearchHelper.php
Normal file
@@ -0,0 +1,383 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers\Helpers;
|
||||
|
||||
use SP\Account\AccountSearch;
|
||||
use SP\Account\AccountsSearchItem;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Html\DataGrid\DataGrid;
|
||||
use SP\Html\DataGrid\DataGridAction;
|
||||
use SP\Html\DataGrid\DataGridActionSearch;
|
||||
use SP\Html\DataGrid\DataGridActionType;
|
||||
use SP\Html\DataGrid\DataGridData;
|
||||
use SP\Html\DataGrid\DataGridHeaderSort;
|
||||
use SP\Html\DataGrid\DataGridPager;
|
||||
use SP\Html\DataGrid\DataGridSort;
|
||||
use SP\Http\Request;
|
||||
use SP\Mgmt\Categories\Category;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Mgmt\Tags\Tag;
|
||||
|
||||
/**
|
||||
* Class AccountSearch
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers\Helpers
|
||||
*/
|
||||
class AccountSearchHelper extends HelperBase
|
||||
{
|
||||
/** @var bool Indica si el filtrado de cuentas está activo */
|
||||
private $filterOn = false;
|
||||
/** @var string */
|
||||
private $sk;
|
||||
/** @var int */
|
||||
private $queryTimeStart = 0;
|
||||
/** @var bool */
|
||||
private $isAjax = false;
|
||||
/** @var AccountSearch */
|
||||
private $search;
|
||||
|
||||
/**
|
||||
* @param boolean $isAjax
|
||||
*/
|
||||
public function setIsAjax($isAjax)
|
||||
{
|
||||
$this->isAjax = $isAjax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la caja de búsqueda
|
||||
*/
|
||||
public function getSearchBox()
|
||||
{
|
||||
$this->view->addTemplate('search-searchbox');
|
||||
|
||||
$this->view->assign('customers', Customer::getItem()->getItemsForSelectByUser());
|
||||
$this->view->assign('categories', Category::getItem()->getItemsForSelect());
|
||||
$this->view->assign('tags', Tag::getItem()->getItemsForSelect());
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los resultados de una búsqueda
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \ReflectionException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
*/
|
||||
public function getSearch()
|
||||
{
|
||||
$this->view->addTemplate('search-index');
|
||||
|
||||
$this->view->assign('isAjax', $this->isAjax);
|
||||
|
||||
$this->filterOn = ($this->search->getSortKey() > 1
|
||||
|| $this->search->getCustomerId()
|
||||
|| $this->search->getCategoryId()
|
||||
|| $this->search->getTagsId()
|
||||
|| $this->search->getTxtSearch()
|
||||
|| $this->search->isSearchFavorites()
|
||||
|| $this->search->isSortViews());
|
||||
|
||||
$UserPreferences = $this->session->getUserPreferences();
|
||||
|
||||
AccountsSearchItem::$accountLink = $UserPreferences->isAccountLink();
|
||||
AccountsSearchItem::$topNavbar = $UserPreferences->isTopNavbar();
|
||||
AccountsSearchItem::$optionalActions = $UserPreferences->isOptionalActions();
|
||||
AccountsSearchItem::$wikiEnabled = $this->configData->isWikiEnabled();
|
||||
AccountsSearchItem::$dokuWikiEnabled = $this->configData->isDokuwikiEnabled();
|
||||
AccountsSearchItem::$isDemoMode = $this->configData->isDemoEnabled();
|
||||
|
||||
if (AccountsSearchItem::$wikiEnabled) {
|
||||
$wikiFilter = array_map(function ($value) {
|
||||
return preg_quote($value, '/');
|
||||
}, $this->configData->getWikiFilter());
|
||||
|
||||
$this->view->assign('wikiFilter', implode('|', $wikiFilter));
|
||||
$this->view->assign('wikiPageUrl', $this->configData->getWikiPageurl());
|
||||
}
|
||||
|
||||
$Grid = $this->getGrid();
|
||||
$Grid->getData()->setData($this->search->processSearchResults());
|
||||
$Grid->updatePager();
|
||||
$Grid->setTime(round(microtime() - $this->queryTimeStart, 5));
|
||||
|
||||
|
||||
// Establecer el filtro de búsqueda en la sesión como un objeto
|
||||
$this->session->setSearchFilters($this->search);
|
||||
|
||||
$this->view->assign('data', $Grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve la matriz a utilizar en la vista
|
||||
*
|
||||
* @return DataGrid
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
private function getGrid()
|
||||
{
|
||||
$icons = $this->view->getTheme()->getIcons();
|
||||
|
||||
$GridActionView = new DataGridAction();
|
||||
$GridActionView->setId(ActionsInterface::ACTION_ACC_VIEW);
|
||||
$GridActionView->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionView->setName(__('Detalles de Cuenta'));
|
||||
$GridActionView->setTitle(__('Detalles de Cuenta'));
|
||||
$GridActionView->setIcon($icons->getIconView());
|
||||
$GridActionView->setReflectionFilter(AccountsSearchItem::class, 'isShowView');
|
||||
$GridActionView->addData('action-id', 'account/view');
|
||||
$GridActionView->addData('action-sk', $this->sk);
|
||||
$GridActionView->addData('onclick', 'account/view');
|
||||
|
||||
$GridActionViewPass = new DataGridAction();
|
||||
$GridActionViewPass->setId(ActionsInterface::ACTION_ACC_VIEW_PASS);
|
||||
$GridActionViewPass->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionViewPass->setName(__('Ver Clave'));
|
||||
$GridActionViewPass->setTitle(__('Ver Clave'));
|
||||
$GridActionViewPass->setIcon($icons->getIconViewPass());
|
||||
$GridActionViewPass->setReflectionFilter(AccountsSearchItem::class, 'isShowViewPass');
|
||||
$GridActionViewPass->addData('action-id', 'account/showpass');
|
||||
$GridActionViewPass->addData('action-full', 1);
|
||||
$GridActionViewPass->addData('action-sk', $this->sk);
|
||||
$GridActionViewPass->addData('onclick', 'account/showpass');
|
||||
|
||||
// Añadir la clase para usar el portapapeles
|
||||
$ClipboardIcon = $icons->getIconClipboard()->setClass('clip-pass-button');
|
||||
|
||||
$GridActionCopyPass = new DataGridAction();
|
||||
$GridActionCopyPass->setId(ActionsInterface::ACTION_ACC_VIEW_PASS);
|
||||
$GridActionCopyPass->setType(DataGridActionType::VIEW_ITEM);
|
||||
$GridActionCopyPass->setName(__('Copiar Clave en Portapapeles'));
|
||||
$GridActionCopyPass->setTitle(__('Copiar Clave en Portapapeles'));
|
||||
$GridActionCopyPass->setIcon($ClipboardIcon);
|
||||
$GridActionCopyPass->setReflectionFilter(AccountsSearchItem::class, 'isShowCopyPass');
|
||||
$GridActionCopyPass->addData('action-id', 'account/showpass');
|
||||
$GridActionCopyPass->addData('action-full', 0);
|
||||
$GridActionCopyPass->addData('action-sk', $this->sk);
|
||||
$GridActionCopyPass->addData('useclipboard', '1');
|
||||
|
||||
$GridActionEdit = new DataGridAction();
|
||||
$GridActionEdit->setId(ActionsInterface::ACTION_ACC_EDIT);
|
||||
$GridActionEdit->setType(DataGridActionType::EDIT_ITEM);
|
||||
$GridActionEdit->setName(__('Editar Cuenta'));
|
||||
$GridActionEdit->setTitle(__('Editar Cuenta'));
|
||||
$GridActionEdit->setIcon($icons->getIconEdit());
|
||||
$GridActionEdit->setReflectionFilter(AccountsSearchItem::class, 'isShowEdit');
|
||||
$GridActionEdit->addData('action-id', ActionsInterface::ACTION_ACC_EDIT);
|
||||
$GridActionEdit->addData('action-sk', $this->sk);
|
||||
$GridActionEdit->addData('onclick', 'account/edit');
|
||||
|
||||
$GridActionCopy = new DataGridAction();
|
||||
$GridActionCopy->setId(ActionsInterface::ACTION_ACC_COPY);
|
||||
$GridActionCopy->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionCopy->setName(__('Copiar Cuenta'));
|
||||
$GridActionCopy->setTitle(__('Copiar Cuenta'));
|
||||
$GridActionCopy->setIcon($icons->getIconCopy());
|
||||
$GridActionCopy->setReflectionFilter(AccountsSearchItem::class, 'isShowCopy');
|
||||
$GridActionCopy->addData('action-id', ActionsInterface::ACTION_ACC_COPY);
|
||||
$GridActionCopy->addData('action-sk', $this->sk);
|
||||
$GridActionCopy->addData('onclick', 'account/copy');
|
||||
|
||||
$GridActionDel = new DataGridAction();
|
||||
$GridActionDel->setId(ActionsInterface::ACTION_ACC_DELETE);
|
||||
$GridActionDel->setType(DataGridActionType::DELETE_ITEM);
|
||||
$GridActionDel->setName(__('Eliminar Cuenta'));
|
||||
$GridActionDel->setTitle(__('Eliminar Cuenta'));
|
||||
$GridActionDel->setIcon($icons->getIconDelete());
|
||||
$GridActionDel->setReflectionFilter(AccountsSearchItem::class, 'isShowDelete');
|
||||
$GridActionDel->addData('action-id', ActionsInterface::ACTION_ACC_DELETE);
|
||||
$GridActionDel->addData('action-sk', $this->sk);
|
||||
$GridActionDel->addData('onclick', 'account/delete');
|
||||
|
||||
$GridActionRequest = new DataGridAction();
|
||||
$GridActionRequest->setId(ActionsInterface::ACTION_ACC_REQUEST);
|
||||
$GridActionRequest->setName(__('Solicitar Modificación'));
|
||||
$GridActionRequest->setTitle(__('Solicitar Modificación'));
|
||||
$GridActionRequest->setIcon($icons->getIconEmail());
|
||||
$GridActionRequest->setReflectionFilter(AccountsSearchItem::class, 'isShowRequest');
|
||||
$GridActionRequest->addData('action-id', ActionsInterface::ACTION_ACC_REQUEST);
|
||||
$GridActionRequest->addData('action-sk', $this->sk);
|
||||
$GridActionRequest->addData('onclick', 'account/show');
|
||||
|
||||
$GridActionOptional = new DataGridAction();
|
||||
$GridActionOptional->setId(0);
|
||||
$GridActionOptional->setName(__('Más Acciones'));
|
||||
$GridActionOptional->setTitle(__('Más Acciones'));
|
||||
$GridActionOptional->setIcon($icons->getIconOptional());
|
||||
$GridActionOptional->setReflectionFilter(AccountsSearchItem::class, 'isShowOptional');
|
||||
$GridActionOptional->addData('onclick', 'account/menu');
|
||||
|
||||
$GridPager = new DataGridPager();
|
||||
$GridPager->setIconPrev($icons->getIconNavPrev());
|
||||
$GridPager->setIconNext($icons->getIconNavNext());
|
||||
$GridPager->setIconFirst($icons->getIconNavFirst());
|
||||
$GridPager->setIconLast($icons->getIconNavLast());
|
||||
$GridPager->setSortKey($this->search->getSortKey());
|
||||
$GridPager->setSortOrder($this->search->getSortOrder());
|
||||
$GridPager->setLimitStart($this->search->getLimitStart());
|
||||
$GridPager->setLimitCount($this->search->getLimitCount());
|
||||
$GridPager->setOnClickFunction('account/sort');
|
||||
$GridPager->setFilterOn($this->filterOn);
|
||||
$GridPager->setSourceAction(new DataGridActionSearch(ActionsInterface::ACTION_ACC_SEARCH));
|
||||
|
||||
$UserPreferences = $this->session->getUserPreferences();
|
||||
|
||||
$showOptionalActions = $UserPreferences->isOptionalActions() || $UserPreferences->isResultsAsCards() || ($UserPreferences->getUserId() === 0 && $this->configData->isResultsAsCards());
|
||||
|
||||
$Grid = new DataGrid();
|
||||
$Grid->setId('gridSearch');
|
||||
$Grid->setDataHeaderTemplate('search-header', $this->view->getBase());
|
||||
$Grid->setDataRowTemplate('search-rows', $this->view->getBase());
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full', 'grid');
|
||||
$Grid->setHeader($this->getHeaderSort());
|
||||
$Grid->setDataActions($GridActionView);
|
||||
$Grid->setDataActions($GridActionViewPass);
|
||||
$Grid->setDataActions($GridActionCopyPass);
|
||||
$Grid->setDataActions($GridActionEdit, !$showOptionalActions);
|
||||
$Grid->setDataActions($GridActionCopy, !$showOptionalActions);
|
||||
$Grid->setDataActions($GridActionDel, !$showOptionalActions);
|
||||
$Grid->setDataActions($GridActionRequest);
|
||||
$Grid->setPager($GridPager);
|
||||
$Grid->setData(new DataGridData());
|
||||
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver la cabecera con los campos de ordenación
|
||||
*
|
||||
* @return DataGridHeaderSort
|
||||
*/
|
||||
private function getHeaderSort()
|
||||
{
|
||||
$icons = $this->view->getTheme()->getIcons();
|
||||
|
||||
$GridSortCustomer = new DataGridSort();
|
||||
$GridSortCustomer->setName(__('Cliente'))
|
||||
->setTitle(__('Ordenar por Cliente'))
|
||||
->setSortKey(AccountSearch::SORT_CUSTOMER)
|
||||
->setIconUp($icons->getIconUp())
|
||||
->setIconDown($icons->getIconDown());
|
||||
|
||||
$GridSortName = new DataGridSort();
|
||||
$GridSortName->setName(__('Nombre'))
|
||||
->setTitle(__('Ordenar por Nombre'))
|
||||
->setSortKey(AccountSearch::SORT_NAME)
|
||||
->setIconUp($icons->getIconUp())
|
||||
->setIconDown($icons->getIconDown());
|
||||
|
||||
$GridSortCategory = new DataGridSort();
|
||||
$GridSortCategory->setName(__('Categoría'))
|
||||
->setTitle(__('Ordenar por Categoría'))
|
||||
->setSortKey(AccountSearch::SORT_CATEGORY)
|
||||
->setIconUp($icons->getIconUp())
|
||||
->setIconDown($icons->getIconDown());
|
||||
|
||||
$GridSortLogin = new DataGridSort();
|
||||
$GridSortLogin->setName(__('Usuario'))
|
||||
->setTitle(__('Ordenar por Usuario'))
|
||||
->setSortKey(AccountSearch::SORT_LOGIN)
|
||||
->setIconUp($icons->getIconUp())
|
||||
->setIconDown($icons->getIconDown());
|
||||
|
||||
$GridSortUrl = new DataGridSort();
|
||||
$GridSortUrl->setName(__('URL / IP'))
|
||||
->setTitle(__('Ordenar por URL / IP'))
|
||||
->setSortKey(AccountSearch::SORT_URL)
|
||||
->setIconUp($icons->getIconUp())
|
||||
->setIconDown($icons->getIconDown());
|
||||
|
||||
$GridHeaderSort = new DataGridHeaderSort();
|
||||
$GridHeaderSort->addSortField($GridSortCustomer)
|
||||
->addSortField($GridSortName)
|
||||
->addSortField($GridSortCategory)
|
||||
->addSortField($GridSortLogin)
|
||||
->addSortField($GridSortUrl);
|
||||
|
||||
return $GridHeaderSort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->queryTimeStart = microtime();
|
||||
$this->sk = SessionUtil::getSessionKey(true);
|
||||
$this->view->assign('sk', $this->sk);
|
||||
$this->setVars();
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer las variables necesarias para las plantillas
|
||||
*/
|
||||
private function setVars()
|
||||
{
|
||||
$userData = $this->session->getUserData();
|
||||
|
||||
$this->view->assign('isAdmin', $userData->isUserIsAdminApp() || $userData->isUserIsAdminAcc());
|
||||
$this->view->assign('showGlobalSearch', $this->configData->isGlobalSearch() && $this->session->getUserProfile()->isAccGlobalSearch());
|
||||
|
||||
// Obtener el filtro de búsqueda desde la sesión
|
||||
$this->search = $this->getFilters();
|
||||
|
||||
$this->view->assign('searchCustomer', $this->search->getCustomerId());
|
||||
$this->view->assign('searchCategory', $this->search->getCategoryId());
|
||||
$this->view->assign('searchTags', $this->search->getTagsId());
|
||||
$this->view->assign('searchTxt', $this->search->getTxtSearch());
|
||||
$this->view->assign('searchGlobal', $this->search->getGlobalSearch());
|
||||
$this->view->assign('searchFavorites', $this->search->isSearchFavorites());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set search filters
|
||||
*
|
||||
* @return AccountSearch
|
||||
*/
|
||||
private function getFilters()
|
||||
{
|
||||
if (empty(Request::analyze('sk'))) {
|
||||
// Obtener el filtro de búsqueda desde la sesión
|
||||
return $this->session->getSearchFilters();
|
||||
}
|
||||
|
||||
$this->search = new AccountSearch();
|
||||
$this->search->setSortKey(Request::analyze('skey', 0));
|
||||
$this->search->setSortOrder(Request::analyze('sorder', 0));
|
||||
$this->search->setLimitStart(Request::analyze('start', 0));
|
||||
$this->search->setLimitCount(Request::analyze('rpp', 0));
|
||||
$this->search->setGlobalSearch(Request::analyze('gsearch', false));
|
||||
$this->search->setCustomerId(Request::analyze('customer', 0));
|
||||
$this->search->setCategoryId(Request::analyze('category', 0));
|
||||
$this->search->setTagsId(Request::analyze('tags'));
|
||||
$this->search->setSearchFavorites(Request::analyze('searchfav', false));
|
||||
$this->search->setTxtSearch(Request::analyze('search'));
|
||||
|
||||
return $this->search;
|
||||
}
|
||||
}
|
||||
81
app/modules/web/Controllers/Helpers/HelperBase.php
Normal file
81
app/modules/web/Controllers/Helpers/HelperBase.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers\Helpers;
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\Config\ConfigData;
|
||||
use SP\Core\Events\EventDispatcher;
|
||||
use SP\Core\Session\Session;
|
||||
use SP\Core\Template;
|
||||
use SP\Core\Traits\InjectableTrait;
|
||||
|
||||
/**
|
||||
* Class HelperBase
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers\Helpers
|
||||
*/
|
||||
abstract class HelperBase
|
||||
{
|
||||
use InjectableTrait;
|
||||
|
||||
/**
|
||||
* @var Template
|
||||
*/
|
||||
protected $view;
|
||||
/**
|
||||
* @var ConfigData
|
||||
*/
|
||||
protected $configData;
|
||||
/**
|
||||
* @var Session
|
||||
*/
|
||||
protected $session;
|
||||
/**
|
||||
* @var EventDispatcher
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Template $template
|
||||
* @param Config $config
|
||||
* @param Session $session
|
||||
* @param EventDispatcher $eventDispatcher
|
||||
*/
|
||||
final public function __construct(Template $template, Config $config, Session $session, EventDispatcher $eventDispatcher)
|
||||
{
|
||||
$this->injectDependencies();
|
||||
|
||||
$this->view = $template;
|
||||
$this->configData = $config->getConfigData();
|
||||
$this->session = $session;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
|
||||
if (method_exists($this, 'initialize')) {
|
||||
$this->initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
292
app/modules/web/Controllers/Helpers/LayoutHelper.php
Normal file
292
app/modules/web/Controllers/Helpers/LayoutHelper.php
Normal file
@@ -0,0 +1,292 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers\Helpers;
|
||||
|
||||
use SP\Bootstrap;
|
||||
use SP\Core\Acl;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\Language;
|
||||
use SP\Core\Plugin\PluginUtil;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Core\UI\Theme;
|
||||
use SP\Core\UI\ThemeInterface;
|
||||
use SP\Html\DataGrid\DataGridAction;
|
||||
use SP\Mgmt\Notices\Notice;
|
||||
use SP\Util\Checks;
|
||||
use SP\Util\Util;
|
||||
|
||||
/**
|
||||
* Class LayoutHelper
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers\Helpers
|
||||
*/
|
||||
class LayoutHelper extends HelperBase
|
||||
{
|
||||
/** @var bool */
|
||||
protected $loggedIn;
|
||||
/** @var ThemeInterface */
|
||||
protected $theme;
|
||||
|
||||
/**
|
||||
* @param Theme $theme
|
||||
*/
|
||||
public function inject(Theme $theme)
|
||||
{
|
||||
$this->theme = $theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar las variables para la vista principal de la aplicación
|
||||
*/
|
||||
public function initBody()
|
||||
{
|
||||
$this->view->assign('startTime', microtime());
|
||||
|
||||
$this->view->addPartial('header');
|
||||
$this->view->addPartial('body-start');
|
||||
|
||||
$this->view->assign('useLayout', true);
|
||||
$this->view->assign('isInstalled', $this->configData->isInstalled());
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
$this->view->assign('appInfo', Util::getAppInfo());
|
||||
$this->view->assign('appVersion', Util::getVersionString());
|
||||
$this->view->assign('isDemoMode', $this->configData->isDemoEnabled());
|
||||
$this->view->assign('icons', $this->theme->getIcons());
|
||||
$this->view->assign('logoIcon', Bootstrap::$WEBURI . '/public/images/logo_icon.png');
|
||||
$this->view->assign('logoNoText', Bootstrap::$WEBURI . '/public/images/logo_icon.svg');
|
||||
$this->view->assign('logo', Bootstrap::$WEBURI . '/public/images/logo_full_bg.png');
|
||||
$this->view->assign('logonobg', Bootstrap::$WEBURI . '/public/images/logo_full_nobg.png');
|
||||
$this->view->assign('httpsEnabled', Checks::httpsEnabled());
|
||||
|
||||
$this->loggedIn = $this->session->isLoggedIn();
|
||||
|
||||
$this->view->assign('loggedIn', $this->loggedIn);
|
||||
$this->view->assign('lang', $this->loggedIn ? Language::$userLang : Language::$globalLang);
|
||||
$this->view->assign('loadApp', $this->session->getAuthCompleted());
|
||||
|
||||
|
||||
try {
|
||||
// Cargar la clave pública en la sesión
|
||||
SessionUtil::loadPublicKey();
|
||||
} catch (SPException $e) {
|
||||
debugLog($e->getMessage(), true);
|
||||
}
|
||||
|
||||
$this->getResourcesLinks();
|
||||
$this->setResponseHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la cabcera de la página
|
||||
*/
|
||||
protected function getResourcesLinks()
|
||||
{
|
||||
$version = Util::getVersionStringNormalized();
|
||||
|
||||
$jsVersionHash = md5($version);
|
||||
$this->view->append('jsLinks', Bootstrap::$WEBROOT . '/public/js/js.php?v=' . $jsVersionHash);
|
||||
$this->view->append('jsLinks', Bootstrap::$WEBROOT . '/public/js/js.php?g=1&v=' . $jsVersionHash);
|
||||
|
||||
$themeInfo = $this->theme->getThemeInfo();
|
||||
|
||||
if (isset($themeInfo['js'])) {
|
||||
$themeJsBase = urlencode($this->theme->getThemePath() . DIRECTORY_SEPARATOR . 'js');
|
||||
$themeJsFiles = urlencode(implode(',', $themeInfo['js']));
|
||||
|
||||
$this->view->append('jsLinks', Bootstrap::$WEBROOT . '/public/js/js.php?f=' . $themeJsFiles . '&b=' . $themeJsBase . '&v=' . $jsVersionHash);
|
||||
}
|
||||
|
||||
if ($this->loggedIn && $this->session->getUserPreferences()->getUserId() > 0) {
|
||||
$resultsAsCards = $this->session->getUserPreferences()->isResultsAsCards();
|
||||
} else {
|
||||
$resultsAsCards = $this->configData->isResultsAsCards();
|
||||
}
|
||||
|
||||
$cssVersionHash = md5($version . $resultsAsCards);
|
||||
$this->view->append('cssLinks', Bootstrap::$WEBROOT . '/public/css/css.php?v=' . $cssVersionHash);
|
||||
|
||||
if (isset($themeInfo['css'])) {
|
||||
if ($resultsAsCards) {
|
||||
$themeInfo['css'][] = 'search-card.min.css';
|
||||
} else {
|
||||
$themeInfo['css'][] = 'search-grid.min.css';
|
||||
}
|
||||
|
||||
if ($this->configData->isDokuwikiEnabled()) {
|
||||
$themeInfo['css'][] = 'styles-wiki.min.css';
|
||||
}
|
||||
|
||||
$themeCssBase = urlencode($this->theme->getThemePath() . DIRECTORY_SEPARATOR . 'css');
|
||||
$themeCssFiles = urlencode(implode(',', $themeInfo['css']));
|
||||
|
||||
$this->view->append('cssLinks', Bootstrap::$WEBROOT . '/public/css/css.php?f=' . $themeCssFiles . '&b=' . $themeCssBase . '&v=' . $jsVersionHash);
|
||||
}
|
||||
|
||||
// Cargar los recursos de los plugins
|
||||
foreach (PluginUtil::getLoadedPlugins() as $Plugin) {
|
||||
$base = str_replace(BASE_PATH, '', $Plugin->getBase());
|
||||
$jsResources = $Plugin->getJsResources();
|
||||
$cssResources = $Plugin->getCssResources();
|
||||
|
||||
if (count($jsResources) > 0) {
|
||||
$this->view->append('jsLinks', Bootstrap::$WEBROOT . '/public/js/js.php?f=' . urlencode(implode(',', $jsResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'js') . '&v=' . $jsVersionHash);
|
||||
}
|
||||
|
||||
if (count($cssResources) > 0) {
|
||||
$this->view->append('cssLinks', Bootstrap::$WEBROOT . '/public/css/css.php?f=' . urlencode(implode(',', $cssResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'css') . '&v=' . $jsVersionHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer las cabeceras HTTP
|
||||
*/
|
||||
private function setResponseHeaders()
|
||||
{
|
||||
// UTF8 Headers
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
// Cache Control
|
||||
header('Cache-Control: public, no-cache, max-age=0, must-revalidate');
|
||||
header('Pragma: public; max-age=0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer la variable de página de la vista
|
||||
*
|
||||
* @param $page
|
||||
*/
|
||||
public function setPage($page)
|
||||
{
|
||||
$this->view->assign('page', $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la mostrar la barra de sesión
|
||||
*/
|
||||
public function getSessionBar()
|
||||
{
|
||||
$this->view->addPartial('sessionbar');
|
||||
|
||||
$userType = null;
|
||||
|
||||
$userData = $this->session->getUserData();
|
||||
$icons = $this->theme->getIcons();
|
||||
|
||||
if ($userData->isUserIsAdminApp()) {
|
||||
$userType = $icons->getIconAppAdmin();
|
||||
} elseif ($userData->isUserIsAdminAcc()) {
|
||||
$userType = $icons->getIconAccAdmin();
|
||||
}
|
||||
|
||||
$this->view->assign('userType', $userType);
|
||||
$this->view->assign('userId', $userData->getUserId());
|
||||
$this->view->assign('userLogin', mb_strtoupper($userData->getUserLogin()));
|
||||
$this->view->assign('userName', $userData->getUserName() ?: mb_strtoupper($this->view->userLogin));
|
||||
$this->view->assign('userGroup', $userData->getUsergroupName());
|
||||
$this->view->assign('showPassIcon', !($this->configData->isLdapEnabled() && $userData->isUserIsLdap()));
|
||||
$this->view->assign('userNotices', count(Notice::getItem()->getAllActiveForUser()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para mostrar el menú de acciones
|
||||
*
|
||||
* @param Acl $acl
|
||||
*/
|
||||
public function getMenu(Acl $acl)
|
||||
{
|
||||
$this->view->addPartial('body-header-menu');
|
||||
|
||||
$icons = $this->theme->getIcons();
|
||||
|
||||
$ActionSearch = new DataGridAction();
|
||||
$ActionSearch->setId('account');
|
||||
$ActionSearch->setTitle(__('Buscar'));
|
||||
$ActionSearch->setIcon($icons->getIconSearch());
|
||||
$ActionSearch->setData(['historyReset' => 1, 'view' => 'search']);
|
||||
|
||||
$this->view->append('actions', $ActionSearch);
|
||||
|
||||
if ($acl->checkUserAccess(ActionsInterface::ACTION_ACC_NEW)) {
|
||||
$ActionNew = new DataGridAction();
|
||||
$ActionNew->setId('account/create');
|
||||
$ActionNew->setTitle(__('Nueva Cuenta'));
|
||||
$ActionNew->setIcon($icons->getIconAdd());
|
||||
$ActionNew->setData(['historyReset' => 0, 'view' => 'account']);
|
||||
|
||||
$this->view->append('actions', $ActionNew);
|
||||
}
|
||||
|
||||
if ($acl->checkUserAccess(ActionsInterface::ACTION_USR)) {
|
||||
$ActionUsr = new DataGridAction();
|
||||
$ActionUsr->setId('users');
|
||||
$ActionUsr->setTitle(__('Usuarios y Accesos'));
|
||||
$ActionUsr->setIcon($icons->getIconAccount());
|
||||
$ActionUsr->setData(['historyReset' => 0, 'view' => 'datatabs']);
|
||||
|
||||
$this->view->append('actions', $ActionUsr);
|
||||
}
|
||||
|
||||
if ($acl->checkUserAccess(ActionsInterface::ACTION_MGM)) {
|
||||
$ActionMgm = new DataGridAction();
|
||||
$ActionMgm->setId('items');
|
||||
$ActionMgm->setTitle(__('Elementos y Personalización'));
|
||||
$ActionMgm->setIcon($icons->getIconGroup());
|
||||
$ActionMgm->setData(['historyReset' => 0, 'view' => 'datatabs']);
|
||||
|
||||
$this->view->append('actions', $ActionMgm);
|
||||
}
|
||||
|
||||
if ($acl->checkUserAccess(ActionsInterface::ACTION_CFG)) {
|
||||
$ActionConfig = new DataGridAction();
|
||||
$ActionConfig->setId('config');
|
||||
$ActionConfig->setTitle(__('Configuración'));
|
||||
$ActionConfig->setIcon($icons->getIconSettings());
|
||||
$ActionConfig->setData(['historyReset' => 1, 'view' => 'config']);
|
||||
|
||||
$this->view->append('actions', $ActionConfig);
|
||||
}
|
||||
|
||||
if ($acl->checkUserAccess(ActionsInterface::ACTION_EVL) && $this->configData->isLogEnabled()) {
|
||||
$ActionEventlog = new DataGridAction();
|
||||
$ActionEventlog->setId('eventlog');
|
||||
$ActionEventlog->setTitle(__('Registro de Eventos'));
|
||||
$ActionEventlog->setIcon($icons->getIconHeadline());
|
||||
$ActionEventlog->setData(['historyReset' => 1, 'view' => 'eventlog']);
|
||||
|
||||
$this->view->append('actions', $ActionEventlog);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $loggedIn
|
||||
*/
|
||||
protected function setLoggedIn($loggedIn)
|
||||
{
|
||||
$this->loggedIn = (bool)$loggedIn;
|
||||
$this->view->assign('loggedIn', $this->loggedIn);
|
||||
}
|
||||
}
|
||||
108
app/modules/web/Controllers/IndexController.php
Normal file
108
app/modules/web/Controllers/IndexController.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers;
|
||||
|
||||
use SP\Controller\ControllerBase;
|
||||
use SP\Http\Response;
|
||||
use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
|
||||
use SP\Util\Util;
|
||||
|
||||
/**
|
||||
* Class IndexController
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers
|
||||
*/
|
||||
class IndexController extends ControllerBase
|
||||
{
|
||||
/**
|
||||
* Index action
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
if (!$this->session->isLoggedIn()) {
|
||||
Response::redirect('index.php?r=login');
|
||||
} else {
|
||||
$LayoutHelper = new LayoutHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$LayoutHelper->setPage('main');
|
||||
$LayoutHelper->initBody();
|
||||
$LayoutHelper->getSessionBar();
|
||||
$LayoutHelper->getMenu($this->acl);
|
||||
|
||||
$this->view->addPartial('body-content');
|
||||
$this->view->addPartial('body-footer');
|
||||
$this->view->addPartial('body-end');
|
||||
|
||||
$this->view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates checking action
|
||||
*/
|
||||
public function checkUpdatesAction()
|
||||
{
|
||||
$this->checkLoggedIn();
|
||||
|
||||
$this->view->addTemplate('update');
|
||||
|
||||
$this->view->assign('hasUpdates', false);
|
||||
$this->view->assign('updateStatus', null);
|
||||
|
||||
if ($this->configData->isCheckUpdates()) {
|
||||
$updates = Util::checkUpdates();
|
||||
|
||||
if (is_array($updates)) {
|
||||
$description = nl2br($updates['description']);
|
||||
$version = $updates['version'];
|
||||
|
||||
$this->view->assign('hasUpdates', true);
|
||||
$this->view->assign('title', $updates['title']);
|
||||
$this->view->assign('url', $updates['url']);
|
||||
$this->view->assign('description', sprintf('%s - %s <br><br>%s', __('Descargar nueva versión'), $version, $description));
|
||||
} else {
|
||||
$this->view->assign('updateStatus', $updates);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->configData->isChecknotices()) {
|
||||
$notices = Util::checkNotices();
|
||||
$numNotices = count($notices);
|
||||
$noticesTitle = '';
|
||||
|
||||
if ($notices !== false && $numNotices > 0) {
|
||||
$noticesTitle = __('Avisos de sysPass') . '<br>';
|
||||
|
||||
foreach ($notices as $notice) {
|
||||
$noticesTitle .= '<br>' . $notice[0];
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->assign('numNotices', $numNotices);
|
||||
$this->view->assign('noticesTitle', $noticesTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
95
app/modules/web/Controllers/ItemsController.php
Normal file
95
app/modules/web/Controllers/ItemsController.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers;
|
||||
|
||||
use SP\Account\AccountUtil;
|
||||
use SP\Controller\RequestControllerTrait;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\DataModel\DataModelInterface;
|
||||
use SP\Util\Json;
|
||||
|
||||
/**
|
||||
* Class ItemsController
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers
|
||||
*/
|
||||
class ItemsController
|
||||
{
|
||||
use RequestControllerTrait;
|
||||
|
||||
/**
|
||||
* ItemsController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver las cuentas visubles por el usuario
|
||||
*
|
||||
* @param $accountId
|
||||
*/
|
||||
public function accountsUserAction($accountId)
|
||||
{
|
||||
$outItems = [];
|
||||
|
||||
foreach (AccountUtil::getAccountsForUser($accountId, $this->session) as $account) {
|
||||
$obj = new \stdClass();
|
||||
$obj->id = $account->account_id;
|
||||
$obj->name = $account->customer_name . ' - ' . $account->account_name;
|
||||
|
||||
$outItems[] = $obj;
|
||||
}
|
||||
|
||||
$this->JsonResponse->setStatus(0);
|
||||
$this->JsonResponse->setData($outItems);
|
||||
$this->JsonResponse->setCsrf(SessionUtil::getSessionKey());
|
||||
|
||||
Json::returnJson($this->JsonResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preparar los elementos para devolverlos
|
||||
*
|
||||
* @param array $items
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareItems(array $items)
|
||||
{
|
||||
$outItems = [];
|
||||
|
||||
/** @var DataModelInterface $item */
|
||||
foreach ($items as $item) {
|
||||
$obj = new \stdClass();
|
||||
$obj->id = $item->getId();
|
||||
$obj->name = $item->getName();
|
||||
|
||||
$outItems[] = $obj;
|
||||
}
|
||||
|
||||
return $outItems;
|
||||
}
|
||||
}
|
||||
129
app/modules/web/Controllers/LoginController.php
Normal file
129
app/modules/web/Controllers/LoginController.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers;
|
||||
|
||||
use SP\Controller\ControllerBase;
|
||||
use SP\Core\SessionFactory;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Html\Html;
|
||||
use SP\Http\Response;
|
||||
use SP\Log\Log;
|
||||
use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
|
||||
use SP\Services\LoginService;
|
||||
use SP\Util\Json;
|
||||
|
||||
/**
|
||||
* Class LoginController
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers
|
||||
*/
|
||||
class LoginController extends ControllerBase
|
||||
{
|
||||
/**
|
||||
* Login action
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function loginAction()
|
||||
{
|
||||
$LoginService = new LoginService($this->config, $this->session, $this->theme, $this->eventDispatcher);
|
||||
return Json::returnJson($LoginService->doLogin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout action
|
||||
*/
|
||||
public function logoutAction()
|
||||
{
|
||||
if ($this->session->isLoggedIn()) {
|
||||
$inactiveTime = abs(round((time() - SessionFactory::getLastActivity()) / 60, 2));
|
||||
$totalTime = abs(round((time() - SessionFactory::getStartActivity()) / 60, 2));
|
||||
|
||||
$Log = new Log();
|
||||
$LogMessage = $Log->getLogMessage();
|
||||
$LogMessage->setAction(__('Finalizar sesión', false));
|
||||
$LogMessage->addDetails(__('Usuario', false), SessionFactory::getUserData()->getUserLogin());
|
||||
$LogMessage->addDetails(__('Tiempo inactivo', false), $inactiveTime . ' min.');
|
||||
$LogMessage->addDetails(__('Tiempo total', false), $totalTime . ' min.');
|
||||
$Log->writeLog();
|
||||
|
||||
SessionUtil::cleanSession();
|
||||
SessionFactory::setLoggedOut(true);
|
||||
|
||||
$LayoutHelper = new LayoutHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$LayoutHelper->setPage('logout');
|
||||
$LayoutHelper->initBody();
|
||||
|
||||
$this->view->addTemplate('logout');
|
||||
|
||||
$this->view->addPartial('body-footer');
|
||||
$this->view->addPartial('body-end');
|
||||
$this->view();
|
||||
} else {
|
||||
Response::redirect('index.php?r=login');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Index action
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$LayoutHelper = new LayoutHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$LayoutHelper->setPage('login');
|
||||
$LayoutHelper->initBody();
|
||||
|
||||
if (SessionFactory::getLoggedOut() === true) {
|
||||
SessionFactory::setLoggedOut();
|
||||
|
||||
$this->view->assign('loggedOut', 1);
|
||||
} else {
|
||||
$this->view->assign('loggedOut', 0);
|
||||
}
|
||||
|
||||
$this->view->addTemplate('login');
|
||||
|
||||
$this->view->addPartial('body-footer');
|
||||
$this->view->addPartial('body-end');
|
||||
|
||||
$this->view->assign('useLayout', false);
|
||||
$this->view->assign('mailEnabled', $this->configData->isMailEnabled());
|
||||
$this->view->assign('updated', SessionFactory::getAppUpdated());
|
||||
|
||||
SessionFactory::setAppUpdated(false);
|
||||
|
||||
$getParams = [];
|
||||
|
||||
// Comprobar y parsear los parámetros GET para pasarlos como POST en los inputs
|
||||
if (count($_GET) > 0) {
|
||||
foreach ($_GET as $param => $value) {
|
||||
$getParams['g_' . Html::sanitizeFull($param)] = Html::sanitizeFull($value);
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->assign('getParams', $getParams);
|
||||
$this->view();
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -22,12 +22,13 @@
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Controller;
|
||||
namespace SP\Modules\Web\Controllers;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Account\AccountUtil;
|
||||
use SP\Config\Config;
|
||||
use SP\Controller\AccountController;
|
||||
use SP\Controller\ControllerBase;
|
||||
use SP\Core\Acl;
|
||||
use SP\Core\ActionsInterface;
|
||||
use SP\Core\DiFactory;
|
||||
@@ -36,7 +37,7 @@ use SP\Core\Init;
|
||||
use SP\Core\Language;
|
||||
use SP\Core\Messages\NoticeMessage;
|
||||
use SP\Core\Plugin\PluginUtil;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\SessionFactory;
|
||||
use SP\Core\SessionUtil;
|
||||
use SP\Core\Task;
|
||||
use SP\Core\Template;
|
||||
@@ -98,30 +99,29 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
$this->view->addTemplate('body-start');
|
||||
|
||||
$this->view->assign('useLayout', true);
|
||||
$this->view->assign('isInstalled', Config::getConfig()->isInstalled());
|
||||
$this->view->assign('isInstalled', $this->configData->isInstalled());
|
||||
$this->view->assign('sk', SessionUtil::getSessionKey(true));
|
||||
$this->view->assign('appInfo', Util::getAppInfo());
|
||||
$this->view->assign('appVersion', Util::getVersionString());
|
||||
$this->view->assign('isDemoMode', Checks::demoIsEnabled());
|
||||
$this->view->assign('icons', DiFactory::getTheme()->getIcons());
|
||||
$this->view->assign('logoIcon', Init::$WEBURI . '/imgs/logo_icon.png');
|
||||
$this->view->assign('logoNoText', Init::$WEBURI . '/imgs/logo_icon.svg');
|
||||
$this->view->assign('logo', Init::$WEBURI . '/imgs/logo_full_bg.png');
|
||||
$this->view->assign('logonobg', Init::$WEBURI . '/imgs/logo_full_nobg.png');
|
||||
$this->view->assign('isDemoMode', $this->configData->isDemoEnabled());
|
||||
$this->view->assign('icons', $this->theme->getIcons());
|
||||
$this->view->assign('logoIcon', Init::$WEBURI . '/public/images/logo_icon.png');
|
||||
$this->view->assign('logoNoText', Init::$WEBURI . '/public/images/logo_icon.svg');
|
||||
$this->view->assign('logo', Init::$WEBURI . '/public/images/logo_full_bg.png');
|
||||
$this->view->assign('logonobg', Init::$WEBURI . '/public/images/logo_full_nobg.png');
|
||||
$this->view->assign('httpsEnabled', Checks::httpsEnabled());
|
||||
$this->view->assign('lang', Init::isLoggedIn() ? Language::$userLang : Language::$globalLang);
|
||||
|
||||
$this->view->assign('loadApp', Session::getAuthCompleted());
|
||||
$this->setLoggedIn(Util::isLoggedIn($this->session));
|
||||
|
||||
$this->view->assign('lang', $this->loggedIn ? Language::$userLang : Language::$globalLang);
|
||||
$this->view->assign('loadApp', SessionFactory::getAuthCompleted());
|
||||
|
||||
$this->setLoggedIn(Init::isLoggedIn());
|
||||
|
||||
try {
|
||||
// Cargar la clave pública en la sesión
|
||||
SessionUtil::loadPublicKey();
|
||||
} catch (SPException $e) {
|
||||
debugLog($e->getMessage(), true);
|
||||
} catch (\phpseclib\Exception\FileNotFoundException $e) {
|
||||
debugLog($e->getMessage(), true);
|
||||
}
|
||||
|
||||
$this->getResourcesLinks();
|
||||
@@ -134,29 +134,28 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
public function getResourcesLinks()
|
||||
{
|
||||
$version = Util::getVersionStringNormalized();
|
||||
$theme = DiFactory::getTheme();
|
||||
|
||||
$jsVersionHash = md5($version);
|
||||
$this->view->append('jsLinks', Init::$WEBROOT . '/js/js.php?v=' . $jsVersionHash);
|
||||
$this->view->append('jsLinks', Init::$WEBROOT . '/js/js.php?g=1&v=' . $jsVersionHash);
|
||||
$this->view->append('jsLinks', Init::$WEBROOT . '/public/js/js.php?v=' . $jsVersionHash);
|
||||
$this->view->append('jsLinks', Init::$WEBROOT . '/public/js/js.php?g=1&v=' . $jsVersionHash);
|
||||
|
||||
$themeInfo = $theme->getThemeInfo();
|
||||
$themeInfo = $this->theme->getThemeInfo();
|
||||
|
||||
if (isset($themeInfo['js'])) {
|
||||
$themeJsBase = urlencode($theme->getThemePath() . DIRECTORY_SEPARATOR . 'js');
|
||||
$themeJsBase = urlencode($this->theme->getThemePath() . DIRECTORY_SEPARATOR . 'js');
|
||||
$themeJsFiles = urlencode(implode(',', $themeInfo['js']));
|
||||
|
||||
$this->view->append('jsLinks', Init::$WEBROOT . '/js/js.php?f=' . $themeJsFiles . '&b=' . $themeJsBase . '&v=' . $jsVersionHash);
|
||||
$this->view->append('jsLinks', Init::$WEBROOT . '/public/js/js.php?f=' . $themeJsFiles . '&b=' . $themeJsBase . '&v=' . $jsVersionHash);
|
||||
}
|
||||
|
||||
if (Init::isLoggedIn() && Session::getUserPreferences()->getUserId() > 0) {
|
||||
$resultsAsCards = Session::getUserPreferences()->isResultsAsCards();
|
||||
if ($this->loggedIn && SessionFactory::getUserPreferences()->getUserId() > 0) {
|
||||
$resultsAsCards = SessionFactory::getUserPreferences()->isResultsAsCards();
|
||||
} else {
|
||||
$resultsAsCards = Checks::resultsCardsIsEnabled();
|
||||
$resultsAsCards = $this->configData->isResultsAsCards();
|
||||
}
|
||||
|
||||
$cssVersionHash = md5($version . $resultsAsCards);
|
||||
$this->view->append('cssLinks', Init::$WEBROOT . '/css/css.php?v=' . $cssVersionHash);
|
||||
$this->view->append('cssLinks', Init::$WEBROOT . '/public/css/css.php?v=' . $cssVersionHash);
|
||||
|
||||
if (isset($themeInfo['css'])) {
|
||||
if ($resultsAsCards) {
|
||||
@@ -165,28 +164,28 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
$themeInfo['css'][] = 'search-grid.min.css';
|
||||
}
|
||||
|
||||
if (Checks::dokuWikiIsEnabled()) {
|
||||
if ($this->configData->isDokuwikiEnabled()) {
|
||||
$themeInfo['css'][] = 'styles-wiki.min.css';
|
||||
}
|
||||
|
||||
$themeCssBase = urlencode($theme->getThemePath() . DIRECTORY_SEPARATOR . 'css');
|
||||
$themeCssBase = urlencode($this->theme->getThemePath() . DIRECTORY_SEPARATOR . 'css');
|
||||
$themeCssFiles = urlencode(implode(',', $themeInfo['css']));
|
||||
|
||||
$this->view->append('cssLinks', Init::$WEBROOT . '/css/css.php?f=' . $themeCssFiles . '&b=' . $themeCssBase . '&v=' . $jsVersionHash);
|
||||
$this->view->append('cssLinks', Init::$WEBROOT . '/public/css/css.php?f=' . $themeCssFiles . '&b=' . $themeCssBase . '&v=' . $jsVersionHash);
|
||||
}
|
||||
|
||||
// Cargar los recursos de los plugins
|
||||
foreach (PluginUtil::getLoadedPlugins() as $Plugin) {
|
||||
$base = str_replace(Init::$SERVERROOT, '', $Plugin->getBase());
|
||||
$base = str_replace(BASE_PATH, '', $Plugin->getBase());
|
||||
$jsResources = $Plugin->getJsResources();
|
||||
$cssResources = $Plugin->getCssResources();
|
||||
|
||||
if (count($jsResources) > 0) {
|
||||
$this->view->append('jsLinks', Init::$WEBROOT . '/js/js.php?f=' . urlencode(implode(',', $jsResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'js') . '&v=' . $jsVersionHash);
|
||||
$this->view->append('jsLinks', Init::$WEBROOT . '/public/js/js.php?f=' . urlencode(implode(',', $jsResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'js') . '&v=' . $jsVersionHash);
|
||||
}
|
||||
|
||||
if (count($cssResources) > 0) {
|
||||
$this->view->append('cssLinks', Init::$WEBROOT . '/css/css.php?f=' . urlencode(implode(',', $cssResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'css') . '&v=' . $jsVersionHash);
|
||||
$this->view->append('cssLinks', Init::$WEBROOT . '/public/css/css.php?f=' . urlencode(implode(',', $cssResources)) . '&b=' . urlencode($base . DIRECTORY_SEPARATOR . 'css') . '&v=' . $jsVersionHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,6 +220,12 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
$this->view->addTemplate('body-end');
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->initialize();
|
||||
$this->getMain();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para la mostrar la barra de sesión
|
||||
*
|
||||
@@ -232,18 +237,18 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
|
||||
$userType = null;
|
||||
|
||||
if ($this->UserData->isUserIsAdminApp()) {
|
||||
if ($this->userData->isUserIsAdminApp()) {
|
||||
$userType = $this->icons->getIconAppAdmin();
|
||||
} elseif ($this->UserData->isUserIsAdminAcc()) {
|
||||
} elseif ($this->userData->isUserIsAdminAcc()) {
|
||||
$userType = $this->icons->getIconAccAdmin();
|
||||
}
|
||||
|
||||
$this->view->assign('userType', $userType);
|
||||
$this->view->assign('userId', $this->UserData->getUserId());
|
||||
$this->view->assign('userLogin', mb_strtoupper($this->UserData->getUserLogin()));
|
||||
$this->view->assign('userName', $this->UserData->getUserName() ?: mb_strtoupper($this->view->userLogin));
|
||||
$this->view->assign('userGroup', $this->UserData->getUsergroupName());
|
||||
$this->view->assign('showPassIcon', !(Config::getConfig()->isLdapEnabled() && $this->UserData->isUserIsLdap()));
|
||||
$this->view->assign('userId', $this->userData->getUserId());
|
||||
$this->view->assign('userLogin', mb_strtoupper($this->userData->getUserLogin()));
|
||||
$this->view->assign('userName', $this->userData->getUserName() ?: mb_strtoupper($this->view->userLogin));
|
||||
$this->view->assign('userGroup', $this->userData->getUsergroupName());
|
||||
$this->view->assign('showPassIcon', !($this->configData->isLdapEnabled() && $this->userData->isUserIsLdap()));
|
||||
$this->view->assign('userNotices', count(Notice::getItem()->getAllActiveForUser()));
|
||||
}
|
||||
|
||||
@@ -302,7 +307,7 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
$this->view->append('actions', $ActionConfig);
|
||||
}
|
||||
|
||||
if (Acl::checkUserAccess(self::ACTION_EVL) && Checks::logIsEnabled()) {
|
||||
if (Acl::checkUserAccess(self::ACTION_EVL) && $this->configData->isLogEnabled()) {
|
||||
$ActionEventlog = new DataGridAction();
|
||||
$ActionEventlog->setId(self::ACTION_EVL);
|
||||
$ActionEventlog->setTitle(__('Registro de Eventos'));
|
||||
@@ -320,8 +325,8 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
{
|
||||
$this->setPage('login');
|
||||
|
||||
if (Session::getLoggedOut() === true) {
|
||||
Session::setLoggedOut(false);
|
||||
if (SessionFactory::getLoggedOut() === true) {
|
||||
SessionFactory::setLoggedOut(false);
|
||||
|
||||
$this->view->assign('loggedOut', 1);
|
||||
} else {
|
||||
@@ -333,10 +338,10 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
$this->view->addTemplate('body-end');
|
||||
|
||||
$this->view->assign('useLayout', false);
|
||||
$this->view->assign('mailEnabled', Checks::mailIsEnabled());
|
||||
$this->view->assign('updated', Session::getAppUpdated());
|
||||
$this->view->assign('mailEnabled', $this->configData->isMailEnabled());
|
||||
$this->view->assign('updated', SessionFactory::getAppUpdated());
|
||||
|
||||
Session::setAppUpdated(false);
|
||||
SessionFactory::setAppUpdated(false);
|
||||
|
||||
$getParams = [];
|
||||
|
||||
@@ -495,7 +500,7 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
$this->view->assign('hasUpdates', false);
|
||||
$this->view->assign('updateStatus', null);
|
||||
|
||||
if (Config::getConfig()->isCheckUpdates()) {
|
||||
if ($this->configData->isCheckUpdates()) {
|
||||
$updates = Util::checkUpdates();
|
||||
|
||||
if (is_array($updates)) {
|
||||
@@ -511,7 +516,7 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (Config::getConfig()->isChecknotices()) {
|
||||
if ($this->configData->isChecknotices()) {
|
||||
$notices = Util::checkNotices();
|
||||
$numNotices = count($notices);
|
||||
$noticesTitle = '';
|
||||
@@ -533,7 +538,6 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
* Realizar las acciones del controlador
|
||||
*
|
||||
* @param mixed $type Tipo de acción
|
||||
* @throws \phpmailer\phpmailerException
|
||||
*/
|
||||
public function doAction($type = null)
|
||||
{
|
||||
@@ -566,7 +570,7 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
|
||||
$this->view->addTemplate('body-header');
|
||||
|
||||
if (Checks::mailIsEnabled() || Request::analyze('f', 0) === 1) {
|
||||
if ($this->configData->isMailEnabled() || Request::analyze('f', 0) === 1) {
|
||||
$this->view->addTemplate('passreset');
|
||||
|
||||
$this->view->assign('login', Request::analyze('login'));
|
||||
@@ -592,7 +596,6 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
* Obtener la vista para mostrar un enlace publicado
|
||||
*
|
||||
* @return bool
|
||||
* @throws \phpmailer\phpmailerException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\FileNotFoundException
|
||||
@@ -622,7 +625,7 @@ class MainController extends ControllerBase implements ActionsInterface
|
||||
$Message = new NoticeMessage();
|
||||
$Message->setTitle(__('Enlace visualizado'));
|
||||
$Message->addDescription(sprintf('%s : %s', __('Cuenta'), $PublicLink->getItemId()));
|
||||
$Message->addDescription(sprintf('%s : %s', __('Origen'), Checks::demoIsEnabled() ? '*.*.*.*' : HttpUtil::getClientAddress(true)));
|
||||
$Message->addDescription(sprintf('%s : %s', __('Origen'), $this->configData->isDemoEnabled() ? '*.*.*.*' : HttpUtil::getClientAddress(true)));
|
||||
$Message->addDescription(sprintf('%s : %s', __('Agente'), Request::getRequestHeaders('HTTP_USER_AGENT')));
|
||||
$Message->addDescription(sprintf('HTTPS : %s', Checks::httpsEnabled() ? 'ON' : 'OFF'));
|
||||
|
||||
69
app/modules/web/Controllers/PassresetController.php
Normal file
69
app/modules/web/Controllers/PassresetController.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers;
|
||||
|
||||
use SP\Controller\ControllerBase;
|
||||
use SP\Http\Request;
|
||||
use SP\Modules\Web\Controllers\Helpers\LayoutHelper;
|
||||
|
||||
/**
|
||||
* Class PassresetController
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers
|
||||
*/
|
||||
class PassresetController extends ControllerBase
|
||||
{
|
||||
/**
|
||||
* Password reset action
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$LayoutHelper = new LayoutHelper($this->view, $this->config, $this->session, $this->eventDispatcher);
|
||||
$LayoutHelper->initBody();
|
||||
$LayoutHelper->setPage('passreset');
|
||||
|
||||
$this->view->addPartial('body-header');
|
||||
|
||||
if ($this->configData->isMailEnabled() || Request::analyze('f', 0) === 1) {
|
||||
$this->view->addTemplate('passreset');
|
||||
|
||||
$this->view->assign('login', Request::analyze('login'));
|
||||
$this->view->assign('email', Request::analyze('email'));
|
||||
|
||||
$this->view->assign('action', Request::analyze('a'));
|
||||
$this->view->assign('hash', Request::analyze('h'));
|
||||
$this->view->assign('time', Request::analyze('t'));
|
||||
|
||||
$this->view->assign('passReset', $this->view->action === 'passreset' && !empty($this->view->hash) && !empty($this->view->time));
|
||||
} else {
|
||||
$this->showError(self::ERR_UNAVAILABLE, false);
|
||||
}
|
||||
|
||||
$this->view->addPartial('body-footer');
|
||||
$this->view->addPartial('body-end');
|
||||
|
||||
$this->view();
|
||||
}
|
||||
}
|
||||
93
app/modules/web/Controllers/SimpleControllerBase.php
Normal file
93
app/modules/web/Controllers/SimpleControllerBase.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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\Controllers;
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\Core\Acl;
|
||||
use SP\Core\Events\EventDispatcher;
|
||||
use SP\Core\Session\Session;
|
||||
use SP\Core\Traits\InjectableTrait;
|
||||
use SP\Core\UI\Theme;
|
||||
use SP\Storage\Database;
|
||||
|
||||
/**
|
||||
* Class SimpleControllerBase
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers
|
||||
*/
|
||||
abstract class SimpleControllerBase
|
||||
{
|
||||
use InjectableTrait;
|
||||
|
||||
/** @var int Módulo a usar */
|
||||
protected $action;
|
||||
/** @var string Nombre del controlador */
|
||||
protected $controllerName;
|
||||
/** @var EventDispatcher */
|
||||
protected $eventDispatcher;
|
||||
/** @var Config */
|
||||
protected $config;
|
||||
/** @var Session */
|
||||
protected $session;
|
||||
/** @var Database */
|
||||
protected $db;
|
||||
/** @var Theme */
|
||||
protected $theme;
|
||||
/** @var Acl */
|
||||
protected $acl;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->injectDependencies();
|
||||
|
||||
$class = static::class;
|
||||
$this->controllerName = substr($class, strrpos($class, '\\') + 1, -strlen('Controller'));
|
||||
|
||||
if (method_exists($this, 'initialize')) {
|
||||
$this->initialize();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
* @param Session $session
|
||||
* @param Database $db
|
||||
* @param Theme $theme
|
||||
* @param EventDispatcher $ev
|
||||
* @param Acl $acl
|
||||
*/
|
||||
public function inject(Config $config, Session $session, Database $db, Theme $theme, EventDispatcher $ev, Acl $acl)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->session = $session;
|
||||
$this->db = $db;
|
||||
$this->theme = $theme;
|
||||
$this->eventDispatcher = $ev;
|
||||
$this->acl = $acl;
|
||||
}
|
||||
}
|
||||
27
app/modules/web/module.php
Normal file
27
app/modules/web/module.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, 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/>.
|
||||
*/
|
||||
|
||||
define('MODULE_PATH', __DIR__);
|
||||
define('VIEW_PATH', MODULE_PATH . DIRECTORY_SEPARATOR . 'themes');
|
||||
define('PLUGINS_PATH', MODULE_PATH . DIRECTORY_SEPARATOR . 'plugins');
|
||||
0
app/modules/web/plugins/.blank
Normal file
0
app/modules/web/plugins/.blank
Normal file
@@ -14,6 +14,7 @@ $color-bluegrey-fg: #607d8b;
|
||||
$color-blue-bg: #e3f2fd;
|
||||
$color-blue-fg: #2196f3;
|
||||
$color-grey: #555;
|
||||
$public-path: '../../../../../../public';
|
||||
|
||||
@mixin box-shadow() {
|
||||
-webkit-box-shadow: 2px 2px 3px -3px rgba(0, 0, 0, 0.14);
|
||||
@@ -1,7 +1,7 @@
|
||||
#login-container {
|
||||
width: 40em;
|
||||
margin: 0 auto;
|
||||
background: transparent url("../imgs/logo_full_bg.png") no-repeat top left;
|
||||
background: transparent url("../../../../public/images/logo_full_bg.png") no-repeat top left;
|
||||
background-size: auto 10em;
|
||||
#boxSpacer {
|
||||
height: 11em;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user