mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-03 15:14:08 +01:00
327 lines
13 KiB
PHP
327 lines
13 KiB
PHP
<?php
|
|
/**
|
|
* sysPass
|
|
*
|
|
* @author nuxsmin
|
|
* @link http://syspass.org
|
|
* @copyright 2012-2015 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\Controller;
|
|
|
|
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
|
|
|
/**
|
|
* Clase encargada de preparar la presentación de las opciones de configuración
|
|
*
|
|
* @package Controller
|
|
*/
|
|
class ConfigC extends Controller implements ActionsInterface
|
|
{
|
|
private $_tabIndex = 0;
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* @param $template \SP\Template con instancia de plantilla
|
|
*/
|
|
public function __construct(\SP\Template $template = null)
|
|
{
|
|
parent::__construct($template);
|
|
|
|
$this->view->assign('tabs', array());
|
|
$this->view->assign('sk', \SP\Common::getSessionKey(true));
|
|
$this->view->assign('isDemoMode', \SP\Util::demoIsEnabled());
|
|
$this->view->assign('isDisabled', (\SP\Util::demoIsEnabled()) ? 'DISABLED' : '');
|
|
}
|
|
|
|
/**
|
|
* Obtener la pestaña de configuración
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function getGeneralTab()
|
|
{
|
|
$this->setAction(self::ACTION_CFG_GENERAL);
|
|
|
|
if (!$this->checkAccess()) {
|
|
return;
|
|
}
|
|
|
|
$themesAvailable = array();
|
|
|
|
$dirThemes = dir(VIEW_PATH);
|
|
|
|
while (false !== ($theme = $dirThemes->read())) {
|
|
if($theme != '.' && $theme != '..') {
|
|
include VIEW_PATH . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . 'index.php';
|
|
|
|
$themesAvailable[$theme] = $themeInfo['name'];
|
|
}
|
|
}
|
|
|
|
$dirThemes->close();
|
|
|
|
$this->view->addTemplate('config');
|
|
|
|
$this->view->assign('langsAvailable',
|
|
array('Español' => 'es_ES',
|
|
'English' => 'en_US',
|
|
'Deutsch' => 'de_DE',
|
|
'Magyar' => 'hu_HU',
|
|
'Français' => 'fr_FR')
|
|
);
|
|
$this->view->assign('currentLang', \SP\Config::getValue('sitelang'));
|
|
$this->view->assign('themesAvailable', $themesAvailable);
|
|
$this->view->assign('currentTheme', \SP\Config::getValue('sitetheme'));
|
|
$this->view->assign('chkLog', (\SP\Config::getValue('log_enabled')) ? 'checked="checked"' : '');
|
|
$this->view->assign('chkDebug', (\SP\Config::getValue('debug')) ? 'checked="checked"' : '');
|
|
$this->view->assign('chkMaintenance', (\SP\Config::getValue('maintenance')) ? 'checked="checked"' : '');
|
|
$this->view->assign('chkUpdates', (\SP\Config::getValue('checkupdates')) ? 'checked="checked"' : '');
|
|
$this->view->assign('sessionTimeout', \SP\Config::getValue('session_timeout'));
|
|
|
|
// Files
|
|
$this->view->assign('chkFiles', (\SP\Config::getValue('files_enabled')) ? 'checked="checked"' : '');
|
|
$this->view->assign('filesAllowedExts', \SP\Config::getValue('files_allowed_exts'));
|
|
$this->view->assign('filesAllowedSize', \SP\Config::getValue('files_allowed_size'));
|
|
|
|
// Accounts
|
|
$this->view->assign('chkGlobalSearch', (\SP\Config::getValue('globalsearch')) ? 'checked="checked"' : '');
|
|
$this->view->assign('chkResultsAsCards', (\SP\Config::getValue('resultsascards')) ? 'checked="checked"' : '');
|
|
$this->view->assign('chkAccountLink', (\SP\Config::getValue('account_link')) ? 'checked="checked"' : '');
|
|
$this->view->assign('accountCount', \SP\Config::getValue('account_count'));
|
|
|
|
// Proxy
|
|
$this->view->assign('chkProxy', (\SP\Config::getValue('proxy_enabled')) ? 'checked="checked"' : '');
|
|
$this->view->assign('proxyServer', \SP\Config::getValue('proxy_server'));
|
|
$this->view->assign('proxyPort', \SP\Config::getValue('proxy_port'));
|
|
$this->view->assign('proxyUser', \SP\Config::getValue('proxy_user'));
|
|
$this->view->assign('proxyPass', \SP\Config::getValue('proxy_pass'));
|
|
|
|
$this->view->assign('actionId', $this->getAction(), 'config');
|
|
$this->view->append('tabs', array('title' => _('General')));
|
|
$this->view->assign('tabIndex', $this->getTabIndex(), 'config');
|
|
}
|
|
|
|
/**
|
|
* Obtener la pestaña de encriptación
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function getEncryptionTab()
|
|
{
|
|
$this->setAction(self::ACTION_CFG_ENCRYPTION);
|
|
|
|
if (!$this->checkAccess()) {
|
|
return;
|
|
}
|
|
|
|
$this->view->addTemplate('encryption');
|
|
|
|
$this->view->assign('lastUpdateMPass', \SP\Config::getConfigDbValue("lastupdatempass"));
|
|
$this->view->assign('tempMasterPassTime', \SP\Config::getConfigDbValue("tempmaster_passtime"));
|
|
$this->view->assign('tempMasterMaxTime', \SP\Config::getConfigDbValue("tempmaster_maxtime"));
|
|
|
|
$this->view->append('tabs', array('title' => _('Encriptación')));
|
|
$this->view->assign('tabIndex', $this->getTabIndex(), 'encryption');
|
|
}
|
|
|
|
/**
|
|
* Obtener la pestaña de copia de seguridad
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function getBackupTab()
|
|
{
|
|
$this->setAction(self::ACTION_CFG_BACKUP);
|
|
|
|
if (!$this->checkAccess()) {
|
|
return;
|
|
}
|
|
|
|
$this->view->addTemplate('backup');
|
|
|
|
$this->view->assign('siteName', \SP\Util::getAppInfo('appname'));
|
|
$this->view->assign('backupDir', \SP\Init::$SERVERROOT . '/backup');
|
|
$this->view->assign('backupPath', \SP\Init::$WEBROOT . '/backup');
|
|
|
|
$this->view->assign('backupFile',
|
|
array('absolute' => $this->view->backupDir . DIRECTORY_SEPARATOR . $this->view->siteName . '.tar.gz',
|
|
'relative' => $this->view->backupPath . '/' . $this->view->siteName . '.tar.gz',
|
|
'filename' => $this->view->siteName . '.tar.gz')
|
|
);
|
|
$this->view->assign('backupDbFile',
|
|
array('absolute' => $this->view->backupDir . DIRECTORY_SEPARATOR . $this->view->siteName . '_db.sql',
|
|
'relative' => $this->view->backupPath . '/' . $this->view->siteName . '_db.sql',
|
|
'filename' => $this->view->siteName . '_db.sql')
|
|
);
|
|
$this->view->assign('lastBackupTime', (file_exists($this->view->backupFile['absolute'])) ? _('Último backup') . ": " . date("r", filemtime($this->view->backupFile['absolute'])) : _('No se encontraron backups'));
|
|
|
|
$this->view->assign('exportFile',
|
|
array('absolute' => $this->view->backupDir . DIRECTORY_SEPARATOR . $this->view->siteName . '.xml',
|
|
'relative' => $this->view->backupPath . '/' . $this->view->siteName . '.xml',
|
|
'filename' => $this->view->siteName . '.xml')
|
|
);
|
|
$this->view->assign('lastExportTime', (file_exists($this->view->exportFile['absolute'])) ? _('Última exportación') . ': ' . date("r", filemtime($this->view->exportFile['absolute'])) : _('No se encontró archivo de exportación'));
|
|
|
|
$this->view->append('tabs', array('title' => _('Copia de Seguridad')));
|
|
$this->view->assign('tabIndex', $this->getTabIndex(), 'backup');
|
|
}
|
|
|
|
/**
|
|
* Obtener la pestaña de Importación
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function getImportTab()
|
|
{
|
|
$this->setAction(self::ACTION_CFG_IMPORT);
|
|
|
|
if (!$this->checkAccess()) {
|
|
return;
|
|
}
|
|
|
|
$this->view->addTemplate('import');
|
|
|
|
$this->view->assign('groups', \SP\DB::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
|
|
$this->view->assign('users', \SP\DB::getValuesForSelect('usrData', 'user_id', 'user_name'));
|
|
|
|
$this->view->append('tabs', array('title' => _('Importar Cuentas')));
|
|
$this->view->assign('tabIndex', $this->getTabIndex(), 'import');
|
|
}
|
|
|
|
/**
|
|
* Obtener la pestaña de información
|
|
* @return bool
|
|
*/
|
|
public function getInfoTab()
|
|
{
|
|
$this->setAction(self::ACTION_CFG_GENERAL);
|
|
|
|
if (!$this->checkAccess()) {
|
|
return;
|
|
}
|
|
|
|
$this->view->addTemplate('info');
|
|
|
|
$this->view->assign('dbInfo', \SP\DB::getDBinfo());
|
|
|
|
$this->view->append('tabs', array('title' => _('Información')));
|
|
$this->view->assign('tabIndex', $this->getTabIndex(), 'info');
|
|
}
|
|
|
|
/**
|
|
* Obtener la pestaña de Wiki
|
|
* @return bool
|
|
*/
|
|
public function getWikiTab()
|
|
{
|
|
$this->setAction(self::ACTION_CFG_WIKI);
|
|
|
|
if (!$this->checkAccess(self::ACTION_CFG_GENERAL)) {
|
|
return;
|
|
}
|
|
|
|
$this->view->addTemplate('wiki');
|
|
|
|
$this->view->assign('chkWiki', (\SP\Config::getValue('wiki_enabled')) ? 'checked="checked"' : '');
|
|
$this->view->assign('wikiSearchUrl', \SP\Config::getValue('wiki_searchurl'));
|
|
$this->view->assign('wikiPageUrl', \SP\Config::getValue('wiki_pageurl'));
|
|
$this->view->assign('wikiFilter', \SP\Config::getValue('wiki_filter'));
|
|
|
|
$this->view->assign('actionId', $this->getAction(), 'wiki');
|
|
$this->view->append('tabs', array('title' => _('Wiki')));
|
|
$this->view->assign('tabIndex', $this->getTabIndex(), 'wiki');
|
|
}
|
|
|
|
/**
|
|
* Obtener la pestaña de LDAP
|
|
* @return bool
|
|
*/
|
|
public function getLdapTab()
|
|
{
|
|
$this->setAction(self::ACTION_CFG_LDAP);
|
|
|
|
if (!$this->checkAccess(self::ACTION_CFG_GENERAL)) {
|
|
return;
|
|
}
|
|
|
|
$this->view->addTemplate('ldap');
|
|
|
|
$this->view->assign('chkLdap', (\SP\Config::getValue('ldap_enabled')) ? 'checked="checked"' : '');
|
|
$this->view->assign('chkLdapADS', (\SP\Config::getValue('ldap_ads')) ? 'checked="checked"' : '');
|
|
$this->view->assign('ldapIsAvailable', \SP\Util::ldapIsAvailable());
|
|
$this->view->assign('ldapServer', \SP\Config::getValue('ldap_server'));
|
|
$this->view->assign('ldapBindUser', \SP\Config::getValue('ldap_binduser'));
|
|
$this->view->assign('ldapBindPass', \SP\Config::getValue('ldap_bindpass'));
|
|
$this->view->assign('ldapBase', \SP\Config::getValue('ldap_base'));
|
|
$this->view->assign('ldapGroup', \SP\Config::getValue('ldap_group'));
|
|
$this->view->assign('groups', \SP\DB::getValuesForSelect('usrGroups', 'usergroup_id', 'usergroup_name'));
|
|
$this->view->assign('profiles', \SP\DB::getValuesForSelect('usrProfiles', 'userprofile_id', 'userprofile_name'));
|
|
$this->view->assign('ldapDefaultGroup', \SP\Config::getValue('ldap_defaultgroup'));
|
|
$this->view->assign('ldapDefaultProfile', \SP\Config::getValue('ldap_defaultprofile'));
|
|
|
|
$this->view->assign('actionId', $this->getAction(), 'ldap');
|
|
$this->view->append('tabs', array('title' => _('LDAP')));
|
|
$this->view->assign('tabIndex', $this->getTabIndex(), 'ldap');
|
|
}
|
|
|
|
/**
|
|
* Obtener la pestaña de Correo
|
|
* @return bool
|
|
*/
|
|
public function getMailTab()
|
|
{
|
|
$this->setAction(self::ACTION_CFG_MAIL);
|
|
|
|
if (!$this->checkAccess(self::ACTION_CFG_GENERAL)) {
|
|
return;
|
|
}
|
|
|
|
$this->view->addTemplate('mail');
|
|
|
|
$this->view->assign('chkMail', (\SP\Config::getValue('mail_enabled')) ? 'checked="checked"' : '');
|
|
$this->view->assign('chkMailRequests', (\SP\Config::getValue('mail_requestsenabled')) ? 'checked="checked"' : '');
|
|
$this->view->assign('chkMailAuth', (\SP\Config::getValue('mail_authenabled')) ? 'checked="checked"' : '');
|
|
$this->view->assign('mailServer', \SP\Config::getValue('mail_server','localhost'));
|
|
$this->view->assign('mailPort', \SP\Config::getValue('mail_port',25));
|
|
$this->view->assign('mailUser', \SP\Config::getValue('mail_user'));
|
|
$this->view->assign('mailPass', \SP\Config::getValue('mail_pass'));
|
|
$this->view->assign('currentMailSecurity', \SP\Config::getValue('mail_security'));
|
|
$this->view->assign('mailFrom', \SP\Config::getValue('mail_from'));
|
|
$this->view->assign('mailSecurity', array('SSL', 'TLS'));
|
|
|
|
$this->view->assign('actionId', $this->getAction(), 'mail');
|
|
$this->view->append('tabs', array('title' => _('Correo')));
|
|
$this->view->assign('tabIndex', $this->getTabIndex(), 'mail');
|
|
}
|
|
|
|
/**
|
|
* Obtener el índice actual de las pestañas
|
|
*
|
|
* @return int
|
|
*/
|
|
private function getTabIndex(){
|
|
$index = $this->_tabIndex;
|
|
$this->_tabIndex++;
|
|
|
|
return $index;
|
|
}
|
|
}
|