* [MOD] Code refactoring

* [ADD] Added PHP 7.2 to Travis CI

Signed-off-by: nuxsmin <nuxsmin@syspass.org>
This commit is contained in:
nuxsmin
2018-10-02 00:31:46 +02:00
parent 337d77d3cc
commit bf82807353
53 changed files with 308 additions and 391 deletions

View File

@@ -3,9 +3,9 @@ language: php
sudo: false
php:
- '7.0'
- '7.1'
# - '7.2'
- '7.0'
- '7.1'
- '7.2'
branches:
only:
@@ -15,27 +15,28 @@ addons:
mariadb: '10.1'
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter && ./cc-test-reporter before-build
- composer self-update
- composer install --prefer-source --no-interaction --dev
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter && ./cc-test-reporter before-build
- composer self-update
- composer install --prefer-source --no-interaction --dev
script: ./vendor/bin/phpunit -c ./tests/phpunit.xml --testsuite Core
after_script:
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then mv ./tests/_output/coverage-clover.xml clover.xml && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT -t clover; fi
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then mv ./tests/_output/coverage-clover.xml clover.xml && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT -t clover; fi
notifications:
email: nuxsmin@syspass.org
on_success: never
on_failure: always
env:
- DB_SERVER=127.0.0.1 DB_NAME=syspass DB_USER=root DB_PASS=
- DB_SERVER=127.0.0.1 DB_NAME=syspass DB_USER=root DB_PASS=
before_install:
- mysql -e 'DROP DATABASE IF EXISTS `'"$DB_NAME"'`;'
- mysql -e 'CREATE DATABASE `'"$DB_NAME"'` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;'
- mysql $DB_NAME < ./schemas/dbstructure.sql
- mysql -e 'DROP DATABASE IF EXISTS `'"$DB_NAME"'`;'
- mysql -e 'CREATE DATABASE `'"$DB_NAME"'` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;'
- mysql $DB_NAME < ./schemas/dbstructure.sql
cache:
directories:

View File

@@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help;
*
* @package SP\Modules\Api\Controllers\Help
*/
class AccountHelp implements HelpInterface
final class AccountHelp implements HelpInterface
{
use HelpTrait;

View File

@@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help;
*
* @package SP\Modules\Api\Controllers\Help
*/
class CategoryHelp implements HelpInterface
final class CategoryHelp implements HelpInterface
{
use HelpTrait;

View File

@@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help;
*
* @package SP\Modules\Api\Controllers\Help
*/
class ClientHelp implements HelpInterface
final class ClientHelp implements HelpInterface
{
use HelpTrait;

View File

@@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help;
*
* @package SP\Modules\Api\Controllers\Help
*/
class ConfigHelp implements HelpInterface
final class ConfigHelp implements HelpInterface
{
use HelpTrait;

View File

@@ -29,7 +29,7 @@ namespace SP\Modules\Api\Controllers\Help;
*
* @package SP\Modules\Api\Controllers\Help
*/
class TagHelp implements HelpInterface
final class TagHelp implements HelpInterface
{
use HelpTrait;

View File

@@ -26,6 +26,7 @@ namespace SP\Modules\Web\Controllers;
use SP\Bootstrap;
use SP\Core\Acl\Acl;
use SP\Core\AppInfoInterface;
use SP\Core\Crypt\CryptSessionHandler;
use SP\Core\Events\Event;
use SP\Core\Language;
@@ -44,7 +45,6 @@ use SP\Services\UserGroup\UserGroupService;
use SP\Services\UserProfile\UserProfileService;
use SP\Storage\Database\DatabaseUtil;
use SP\Storage\Database\DBStorageInterface;
use SP\Util\Util;
/**
* Class ConfigManagerController
@@ -279,7 +279,7 @@ final class ConfigManagerController extends ControllerBase
$template->addTemplate('backup');
$template->assign('pharIsAvailable', $this->extensionChecker->checkPharAvailable());
$template->assign('siteName', Util::getAppInfo('appname'));
$template->assign('siteName', AppInfoInterface::APP_NAME);
$template->assign('backupDir', BACKUP_PATH);
$template->assign('backupPath', Bootstrap::$WEBROOT . '/backup');

View File

@@ -38,7 +38,7 @@ use SP\Services\UserGroup\UserGroupService;
*
* @package SP\Modules\Web\Controllers\Helpers
*/
class ItemPresetHelper extends HelperBase
final class ItemPresetHelper extends HelperBase
{
/**
* @var SelectItemAdapter

View File

@@ -27,6 +27,7 @@ namespace SP\Modules\Web\Controllers\Helpers;
use SP\Bootstrap;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
use SP\Core\AppInfoInterface;
use SP\Core\Crypt\CryptPKI;
use SP\Core\Exceptions\SPException;
use SP\Core\Language;
@@ -36,7 +37,6 @@ use SP\Html\DataGrid\DataGridAction;
use SP\Http\Uri;
use SP\Plugin\PluginManager;
use SP\Services\Install\Installer;
use SP\Util\Util;
use SP\Util\Version;
/**
@@ -101,8 +101,11 @@ final class LayoutHelper extends HelperBase
$this->view->assign('isInstalled', $this->configData->isInstalled());
$this->view->assign('sk', $this->loggedIn ? $this->context->generateSecurityKey() : '');
$this->view->assign('appInfo', Util::getAppInfo());
$this->view->assign('appVersion', Installer::VERSION_TEXT);
$this->view->assign('app_name', AppInfoInterface::APP_NAME);
$this->view->assign('app_desc', AppInfoInterface::APP_DESC);
$this->view->assign('app_website_url', AppInfoInterface::APP_WEBSITE_URL);
$this->view->assign('app_blog_url', AppInfoInterface::APP_BLOG_URL);
$this->view->assign('app_version', Installer::VERSION_TEXT);
$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');
@@ -336,7 +339,7 @@ final class LayoutHelper extends HelperBase
'route' => Acl::getActionRoute(ActionsInterface::PLUGIN)
]);
$actions[] = $actionPlugins;
$actions[] = $actionPlugins;
}
if ($acl->checkUserAccess(ActionsInterface::CONFIG)) {

View File

@@ -45,7 +45,7 @@ use SP\Util\Filter;
*
* @package SP\Modules\Web\Controllers
*/
class ItemPresetController extends ControllerBase implements CrudControllerInterface
final class ItemPresetController extends ControllerBase implements CrudControllerInterface
{
use JsonTrait, ItemTrait;

View File

@@ -26,10 +26,10 @@ namespace SP\Modules\Web\Controllers;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use SP\Core\AppInfoInterface;
use SP\Core\Exceptions\CheckException;
use SP\Http\JsonResponse;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Util\Util;
use SP\Util\Version;
/**
@@ -44,6 +44,9 @@ final class StatusController extends SimpleControllerBase
/**
* checkReleaseAction
*
* @return bool
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkReleaseAction()
@@ -52,7 +55,7 @@ final class StatusController extends SimpleControllerBase
$this->extensionChecker->checkCurlAvailable(true);
$request = $this->dic->get(Client::class)
->request('GET', Util::getAppInfo('appupdates'));
->request('GET', AppInfoInterface::APP_UPDATES_URL);
if ($request->getStatusCode() === 200
&& strpos($request->getHeaderLine('content-type'), 'application/json') !== false
@@ -101,6 +104,9 @@ final class StatusController extends SimpleControllerBase
/**
* checkNoticesAction
*
* @return bool
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkNoticesAction()
@@ -109,7 +115,7 @@ final class StatusController extends SimpleControllerBase
$this->extensionChecker->checkCurlAvailable(true);
$request = $this->dic->get(Client::class)
->request('GET', Util::getAppInfo('appnotices'));
->request('GET', AppInfoInterface::APP_NOTICES_URL);
if ($request->getStatusCode() === 200
&& strpos($request->getHeaderLine('content-type'), 'application/json') !== false

View File

@@ -2,7 +2,7 @@
<!DOCTYPE html>
<html lang="<?php echo $lang; ?>">
<head>
<title><?php echo $appInfo['appname'], ' :: ', $appInfo['appdesc']; ?></title>
<title><?php printf('%s :: %s', $app_name, $app_desc); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="<?php echo $logoIcon; ?>">
@@ -21,7 +21,8 @@
<div id="taskStatus"></div>
</div>
<div id="container" class="<?php echo $page; ?>" data-page="<?php echo $page; ?>" data-upgraded="<?php echo (int)$this->isUpgraded(); ?>">
<div id="container" class="<?php echo $page; ?>" data-page="<?php echo $page; ?>"
data-upgraded="<?php echo (int)$this->isUpgraded(); ?>">
<?php
if (isset($useFixedHeader)):
include $this->includePartial('fixed-header');

View File

@@ -83,7 +83,7 @@
<?php if (isset($useMenu) && $loggedIn): ?>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title"><?php echo $appInfo['appname']; ?></span>
<span class="mdl-layout-title"><?php echo $app_name; ?></span>
<nav class="mdl-navigation">
<?php /** @var \SP\Html\DataGrid\DataGridAction $action */
foreach ($actions as $action): ?>
@@ -165,7 +165,7 @@
<span class="status-info"><?php echo __('Demo'); ?></span>
<?php endif; ?>
<?php echo $appInfo['appname'], ' ', $appVersion; ?>
<?php echo $app_name, ' ', $app_version; ?>
</a>
</nav>
</div>

View File

@@ -49,13 +49,13 @@
</div>
<div id="project">
<a id="app-info" href="<?php echo $appInfo['appwebsite']; ?>" target="_blank">
<?php echo $appInfo['appname'], ' ', $appVersion; ?>
<a id="app-info" href="<?php echo $app_website_url; ?>" target="_blank">
<?php echo $app_name, ' ', $app_version; ?>
</a>
<span for="app-info"
class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large"><?php echo __('Ayuda :: FAQ :: Changelog'); ?></span>
&nbsp;::&nbsp;
<a id="app-project" href="<?php echo $appInfo['appblog']; ?>" target="_blank">cygnux.org</a>
<a id="app-project" href="<?php echo $app_blog_url; ?>" target="_blank">cygnux.org</a>
<span for="app-project"
class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large"><?php echo __('Un proyecto de cygnux.org'); ?></span>
</div>

View File

@@ -5,7 +5,7 @@
?>
<div id="actions" class="installer" align="center">
<div id="page-title">
<h1><?php printf(__('Instalación %s'), $appVersion); ?></h1>
<h1><?php printf(__('Instalación %s'), $app_version); ?></h1>
</div>
<?php include $this->includePartial('error-list'); ?>

View File

@@ -29,7 +29,10 @@
"doctrine/common": "~v2.7",
"guzzlehttp/guzzle": "~6.3",
"monolog/monolog": "^1.23",
"ext-pdo": "*"
"ext-pdo": "*",
"ext-dom": "*",
"ext-gd": "*",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^6",

View File

@@ -0,0 +1,44 @@
<?php
/**
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Core;
/**
* Interface AppInfoInterface
*
* @package SP\Core
*/
interface AppInfoInterface
{
const APP_NAME = 'sysPass';
const APP_DESC = 'Systems Password Manager';
const APP_ALIAS = 'SPM';
const APP_WEBSITE_URL = 'https://www.syspass.org';
const APP_BLOG_URL = 'https://www.cygnux.org';
const APP_DOC_URL = 'https://doc.syspass.org';
const APP_UPDATES_URL = 'https://api.github.com/repos/nuxsmin/sysPass/releases/latest';
const APP_NOTICES_URL = 'https://api.github.com/repos/nuxsmin/sysPass/issues?milestone=none&state=open&labels=Notices';
const APP_ISSUES_URL = 'https://github.com/nuxsmin/sysPass/issues';
}

View File

@@ -31,7 +31,7 @@ defined('APP_ROOT') || die();
*
* @package SP
*/
class SessionUtil
final class SessionUtil
{
/**
* Limpiar la sesión del usuario

View File

@@ -34,7 +34,7 @@ defined('APP_ROOT') || die();
*
* @package SP\Core
*/
class ThemeIcons
final class ThemeIcons
{
/**
* @var IconInterface[]

View File

@@ -38,14 +38,14 @@ final class DataGrid extends DataGridBase
*
* @var string
*/
private $_title = '';
private $title = '';
/**
* @return string
*/
public function getTitle()
{
return $this->_title;
return $this->title;
}
/**
@@ -55,7 +55,7 @@ final class DataGrid extends DataGridBase
*/
public function setTitle($title)
{
$this->_title = $title;
$this->title = $title;
return $this;
}

View File

@@ -36,14 +36,14 @@ final class DataGridActionSearch extends DataGridActionBase
/**
* @var string
*/
private $_onSubmitFunction = '';
private $onSubmitFunction = '';
/**
* Los argumentos de la función OnSubmit
*
* @var array
*/
private $_onSubmitArgs = [];
private $onSubmitArgs = [];
/**
* DataGridActionSearch constructor.
@@ -64,11 +64,11 @@ final class DataGridActionSearch extends DataGridActionBase
{
$args = [];
foreach ($this->_onSubmitArgs as $arg) {
foreach ($this->onSubmitArgs as $arg) {
$args[] = (!is_numeric($arg) && $arg !== 'this') ? '\'' . $arg . '\'' : $arg;
}
return count($args) > 0 ? 'return ' . $this->_onSubmitFunction . '(' . implode(',', $args) . ');' : $this->_onSubmitFunction;
return count($args) > 0 ? 'return ' . $this->onSubmitFunction . '(' . implode(',', $args) . ');' : $this->onSubmitFunction;
}
/**
@@ -76,7 +76,7 @@ final class DataGridActionSearch extends DataGridActionBase
*/
public function setOnSubmitFunction($onSubmitFunction)
{
$this->_onSubmitFunction = $onSubmitFunction;
$this->onSubmitFunction = $onSubmitFunction;
}
/**
@@ -84,6 +84,6 @@ final class DataGridActionSearch extends DataGridActionBase
*/
public function setOnSubmitArgs($args)
{
$this->_onSubmitArgs[] = $args;
$this->onSubmitArgs[] = $args;
}
}

View File

@@ -44,87 +44,87 @@ abstract class DataGridBase implements DataGridInterface
*
* @var int
*/
protected $_time = 0;
protected $time = 0;
/**
* El id de la matriz
*
* @var string
*/
protected $_id = '';
protected $id = '';
/**
* La cabecera de la matriz
*
* @var DataGridHeaderInterface
*/
protected $_header;
protected $header;
/**
* Los datos de la matriz
*
* @var DataGridData
*/
protected $_data;
protected $data;
/**
* El paginador
*
* @var DataGridPagerBase
*/
protected $_pager;
protected $pager;
/**
* Las acciones asociadas a los elementos de la matriz
*
* @var DataGridActionInterface[]
*/
protected $_actions;
protected $actions;
/**
* @var int
*/
protected $_actionsCount = 0;
protected $actionsCount = 0;
/**
* Las acciones asociadas a los elementos de la matriz que se muestran en un menú
*
* @var DataGridActionInterface[]
*/
protected $_actionsMenu;
protected $actionsMenu;
/**
* @var int
*/
protected $_actionsMenuCount = 0;
protected $actionsMenuCount = 0;
/**
* La acción a realizar al cerrar la matriz
*
* @var int
*/
protected $_onCloseAction = 0;
protected $onCloseAction = 0;
/**
* La plantilla a utilizar para presentar la cabecera
*
* @var string
*/
protected $_headerTemplate;
protected $headerTemplate;
/**
* La plantilla a utilizar para presentar las acciones
*
* @var string
*/
protected $_actionsTemplate;
protected $actionsTemplate;
/**
* La plantilla a utilizar para presentar el paginador
*
* @var string
*/
protected $_pagerTemplate;
protected $pagerTemplate;
/**
* La plantilla a utilizar para presentar los datos
*
* @var string
*/
protected $_rowsTemplate;
protected $rowsTemplate;
/**
* La plantilla a utilizar para presentar la tabla
*
* @var string
*/
protected $_tableTemplate;
protected $tableTemplate;
/**
* @var Theme
*/
@@ -145,7 +145,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getOnCloseAction()
{
return $this->_onCloseAction;
return $this->onCloseAction;
}
/**
@@ -155,7 +155,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function setOnCloseAction(ActionsInterface $action)
{
$this->_onCloseAction = $action;
$this->onCloseAction = $action;
return $this;
}
@@ -165,7 +165,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getId()
{
return $this->_id;
return $this->id;
}
/**
@@ -175,7 +175,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function setId($id)
{
$this->_id = $id;
$this->id = $id;
return $this;
}
@@ -185,7 +185,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getHeader()
{
return $this->_header;
return $this->header;
}
/**
@@ -195,7 +195,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function setHeader(DataGridHeaderInterface $header)
{
$this->_header = $header;
$this->header = $header;
return $this;
}
@@ -205,7 +205,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getData()
{
return $this->_data;
return $this->data;
}
/**
@@ -215,7 +215,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function setData(DataGridDataInterface $data)
{
$this->_data = $data;
$this->data = $data;
return $this;
}
@@ -229,24 +229,24 @@ abstract class DataGridBase implements DataGridInterface
public function setDataActions(DataGridActionInterface $action, $isMenu = false)
{
if ($isMenu === false) {
if (null === $this->_actions) {
$this->_actions = new SplObjectStorage();
if (null === $this->actions) {
$this->actions = new SplObjectStorage();
}
$this->_actions->attach($action);
$this->actions->attach($action);
if (!$action->isSkip()) {
$this->_actionsCount++;
$this->actionsCount++;
}
} else {
if (null === $this->_actionsMenu) {
$this->_actionsMenu = new SplObjectStorage();
if (null === $this->actionsMenu) {
$this->actionsMenu = new SplObjectStorage();
}
$this->_actionsMenu->attach($action);
$this->actionsMenu->attach($action);
if (!$action->isSkip()) {
$this->_actionsMenuCount++;
$this->actionsMenuCount++;
}
}
@@ -258,7 +258,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getDataActions()
{
return $this->_actions;
return $this->actions;
}
/**
@@ -280,7 +280,7 @@ abstract class DataGridBase implements DataGridInterface
public function setDataHeaderTemplate($template, $base = null)
{
try {
$this->_headerTemplate = $this->checkTemplate($template, $base);
$this->headerTemplate = $this->checkTemplate($template, $base);
} catch (FileNotFoundException $e) {
processException($e);
}
@@ -316,7 +316,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getDataHeaderTemplate()
{
return $this->_headerTemplate;
return $this->headerTemplate;
}
/**
@@ -329,7 +329,7 @@ abstract class DataGridBase implements DataGridInterface
public function setDataActionsTemplate($template)
{
try {
$this->_actionsTemplate = $this->checkTemplate($template);
$this->actionsTemplate = $this->checkTemplate($template);
} catch (FileNotFoundException $e) {
logger($e->getMessage());
}
@@ -344,7 +344,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getDataActionsTemplate()
{
return $this->_actionsTemplate;
return $this->actionsTemplate;
}
/**
@@ -358,7 +358,7 @@ abstract class DataGridBase implements DataGridInterface
public function setDataPagerTemplate($template, $base = null)
{
try {
$this->_pagerTemplate = $this->checkTemplate($template, $base);
$this->pagerTemplate = $this->checkTemplate($template, $base);
} catch (FileNotFoundException $e) {
logger($e->getMessage());
}
@@ -373,7 +373,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getDataPagerTemplate()
{
return $this->_pagerTemplate;
return $this->pagerTemplate;
}
/**
@@ -385,7 +385,7 @@ abstract class DataGridBase implements DataGridInterface
public function setDataRowTemplate($template, $base = null)
{
try {
$this->_rowsTemplate = $this->checkTemplate($template, $base);
$this->rowsTemplate = $this->checkTemplate($template, $base);
} catch (FileNotFoundException $e) {
processException($e);
}
@@ -398,7 +398,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getDataRowTemplate()
{
return $this->_rowsTemplate;
return $this->rowsTemplate;
}
/**
@@ -408,7 +408,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getPager()
{
return $this->_pager;
return $this->pager;
}
/**
@@ -420,7 +420,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function setPager(DataGridPagerInterface $pager)
{
$this->_pager = $pager;
$this->pager = $pager;
return $this;
}
@@ -430,8 +430,8 @@ abstract class DataGridBase implements DataGridInterface
*/
public function updatePager()
{
if ($this->_pager instanceof DataGridPagerInterface) {
$this->_pager->setTotalRows($this->_data->getDataCount());
if ($this->pager instanceof DataGridPagerInterface) {
$this->pager->setTotalRows($this->data->getDataCount());
}
return $this;
@@ -442,7 +442,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getTime()
{
return abs($this->_time);
return abs($this->time);
}
/**
@@ -452,7 +452,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function setTime($time)
{
$this->_time = $time;
$this->time = $time;
return $this;
}
@@ -464,7 +464,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getDataActionsMenu()
{
return $this->_actionsMenu;
return $this->actionsMenu;
}
/**
@@ -478,7 +478,7 @@ abstract class DataGridBase implements DataGridInterface
{
$actions = [];
foreach ($this->_actions as $action) {
foreach ($this->actions as $action) {
if ($action->getRuntimeFilter()($filter)) {
$actions[] = $action;
}
@@ -498,7 +498,7 @@ abstract class DataGridBase implements DataGridInterface
{
$actions = [];
foreach ($this->_actionsMenu as $action) {
foreach ($this->actionsMenu as $action) {
if ($action->getRuntimeFilter()($filter)) {
$actions[] = $action;
}
@@ -512,7 +512,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getDataTableTemplate()
{
return $this->_tableTemplate;
return $this->tableTemplate;
}
/**
@@ -524,7 +524,7 @@ abstract class DataGridBase implements DataGridInterface
public function setDataTableTemplate($template, $base = null)
{
try {
$this->_tableTemplate = $this->checkTemplate($template, $base);
$this->tableTemplate = $this->checkTemplate($template, $base);
} catch (FileNotFoundException $e) {
processException($e);
}
@@ -537,7 +537,7 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getDataActionsMenuCount()
{
return $this->_actionsMenuCount;
return $this->actionsMenuCount;
}
/**
@@ -545,6 +545,6 @@ abstract class DataGridBase implements DataGridInterface
*/
public function getDataActionsCount()
{
return $this->_actionsCount;
return $this->actionsCount;
}
}

View File

@@ -41,36 +41,36 @@ abstract class DataGridDataBase implements DataGridDataInterface
*
* @var array
*/
private $_data = [];
private $data = [];
/**
* Las columnas a mostrar de los datos obtenidos
*
* @var array
*/
private $_sources = [];
private $sources = [];
/**
* La columna que identifica cada elemento de los datos de la matriz
*
* @var int
*/
private $_sourceId = 0;
private $sourceId = 0;
/**
* Las columnas a mostrar de los datos obtenidos que son representadas con iconos
*
* @var array
*/
private $_sourcesWithIcon = [];
private $sourcesWithIcon = [];
/**
* @var int
*/
private $_dataCount = 0;
private $dataCount = 0;
/**
* @return array
*/
public function getDataRowSourcesWithIcon()
{
return $this->_sourcesWithIcon;
return $this->sourcesWithIcon;
}
/**
@@ -81,7 +81,7 @@ abstract class DataGridDataBase implements DataGridDataInterface
*/
public function addDataRowSource($source, $isMethod = false, callable $filter = null, $truncate = true)
{
$this->_sources[] = [
$this->sources[] = [
'name' => $source,
'isMethod' => $isMethod,
'filter' => $filter,
@@ -94,7 +94,7 @@ abstract class DataGridDataBase implements DataGridDataInterface
*/
public function setDataRowSourceId($id)
{
$this->_sourceId = $id;
$this->sourceId = $id;
}
/**
@@ -102,7 +102,7 @@ abstract class DataGridDataBase implements DataGridDataInterface
*/
public function getDataRowSources()
{
return $this->_sources;
return $this->sources;
}
/**
@@ -110,7 +110,7 @@ abstract class DataGridDataBase implements DataGridDataInterface
*/
public function getDataRowSourceId()
{
return $this->_sourceId;
return $this->sourceId;
}
/**
@@ -118,7 +118,7 @@ abstract class DataGridDataBase implements DataGridDataInterface
*/
public function getData()
{
return $this->_data;
return $this->data;
}
/**
@@ -126,8 +126,8 @@ abstract class DataGridDataBase implements DataGridDataInterface
*/
public function setData(QueryResult $queryResult)
{
$this->_dataCount = $queryResult->getTotalNumRows();
$this->_data = $queryResult->getDataAsArray();
$this->dataCount = $queryResult->getTotalNumRows();
$this->data = $queryResult->getDataAsArray();
}
/**
@@ -137,7 +137,7 @@ abstract class DataGridDataBase implements DataGridDataInterface
*/
public function addDataRowSourceWithIcon($source, IconInterface $icon, $value = 1)
{
$this->_sourcesWithIcon[] = [
$this->sourcesWithIcon[] = [
'field' => $source,
'icon' => $icon,
'value' => $value
@@ -151,6 +151,6 @@ abstract class DataGridDataBase implements DataGridDataInterface
*/
public function getDataCount()
{
return $this->_dataCount;
return $this->dataCount;
}
}

View File

@@ -38,23 +38,23 @@ abstract class DataGridHeaderBase implements DataGridHeaderInterface
*
* @var array
*/
private $_headers = array();
private $headers = [];
/**
* El ancho de las columnas
*
* @var int
*/
private $_width = 0;
private $width = 0;
/**
* @param $header string
*/
public function addHeader($header)
{
$this->_headers[] = $header;
$this->headers[] = $header;
$numHeaders = count($this->_headers);
$this->_width = ($numHeaders > 0) ? floor(65 / $numHeaders) : 65;
$numHeaders = count($this->headers);
$this->width = ($numHeaders > 0) ? floor(65 / $numHeaders) : 65;
}
/**
@@ -62,7 +62,7 @@ abstract class DataGridHeaderBase implements DataGridHeaderInterface
*/
public function getWidth()
{
return $this->_width;
return $this->width;
}
/**
@@ -70,6 +70,6 @@ abstract class DataGridHeaderBase implements DataGridHeaderInterface
*/
public function getHeaders()
{
return $this->_headers;
return $this->headers;
}
}

View File

@@ -38,19 +38,19 @@ final class DataGridHeaderSort extends DataGridHeaderBase
/**
* @var DataGridActionInterface[]
*/
private $_actions;
private $actions;
/**
* @var DataGridSortInterface[]
*/
private $_sortFields;
private $sortFields;
/**
* @return DataGridSortInterface[]
*/
public function getSortFields()
{
return $this->_sortFields;
return $this->sortFields;
}
/**
@@ -58,7 +58,7 @@ final class DataGridHeaderSort extends DataGridHeaderBase
*/
public function getActions()
{
return $this->_actions;
return $this->actions;
}
/**
@@ -66,11 +66,11 @@ final class DataGridHeaderSort extends DataGridHeaderBase
*/
public function addAction($action)
{
if (null === $this->_actions) {
$this->_actions = new SplObjectStorage();
if (null === $this->actions) {
$this->actions = new SplObjectStorage();
}
$this->_actions->attach($action);
$this->actions->attach($action);
}
/**
@@ -80,11 +80,11 @@ final class DataGridHeaderSort extends DataGridHeaderBase
*/
public function addSortField($field)
{
if (null === $this->_sortFields) {
$this->_sortFields = new SplObjectStorage();
if (null === $this->sortFields) {
$this->sortFields = new SplObjectStorage();
}
$this->_sortFields->attach($field);
$this->sortFields->attach($field);
return $this;
}

View File

@@ -38,66 +38,66 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
/**
* @var int
*/
protected $_sortKey = 0;
protected $sortKey = 0;
/**
* @var int
*/
protected $_sortOrder = 0;
protected $sortOrder = 0;
/**
* @var int
*/
protected $_limitStart = 0;
protected $limitStart = 0;
/**
* @var int
*/
protected $_limitCount = 0;
protected $limitCount = 0;
/**
* @var int
*/
protected $_totalRows = 0;
protected $totalRows = 0;
/**
* @var bool
*/
protected $_filterOn = false;
protected $filterOn = false;
/**
* @var string
*/
protected $_onClickFunction = '';
protected $onClickFunction = '';
/**
* @var array
*/
protected $_onClickArgs = array();
protected $onClickArgs = [];
/**
* @var IconInterface
*/
protected $_iconPrev;
protected $iconPrev;
/**
* @var IconInterface
*/
protected $_iconNext;
protected $iconNext;
/**
* @var IconInterface
*/
protected $_iconFirst;
protected $iconFirst;
/**
* @var IconInterface
*/
protected $_iconLast;
protected $iconLast;
/**
* @var DataGridActionSearch
*/
protected $_sourceAction;
protected $sourceAction;
/**
* @var string
*/
protected $_sk;
protected $sk;
/**
* @return int
*/
public function getSortOrder()
{
return $this->_sortOrder;
return $this->sortOrder;
}
/**
@@ -107,7 +107,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setSortOrder($sortOrder)
{
$this->_sortOrder = $sortOrder;
$this->sortOrder = $sortOrder;
return $this;
}
@@ -119,7 +119,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setSk($sk)
{
$this->_sk = $sk;
$this->sk = $sk;
return $this;
}
@@ -129,7 +129,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getIconPrev()
{
return $this->_iconPrev;
return $this->iconPrev;
}
/**
@@ -139,7 +139,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setIconPrev(IconInterface $iconPrev)
{
$this->_iconPrev = $iconPrev;
$this->iconPrev = $iconPrev;
return $this;
}
@@ -149,7 +149,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getIconNext()
{
return $this->_iconNext;
return $this->iconNext;
}
/**
@@ -159,7 +159,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setIconNext(IconInterface $iconNext)
{
$this->_iconNext = $iconNext;
$this->iconNext = $iconNext;
return $this;
}
@@ -169,7 +169,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getIconFirst()
{
return $this->_iconFirst;
return $this->iconFirst;
}
/**
@@ -179,7 +179,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setIconFirst(IconInterface $iconFirst)
{
$this->_iconFirst = $iconFirst;
$this->iconFirst = $iconFirst;
return $this;
}
@@ -189,7 +189,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getIconLast()
{
return $this->_iconLast;
return $this->iconLast;
}
/**
@@ -199,7 +199,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setIconLast(IconInterface $iconLast)
{
$this->_iconLast = $iconLast;
$this->iconLast = $iconLast;
return $this;
}
@@ -211,7 +211,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getSortKey()
{
return $this->_sortKey;
return $this->sortKey;
}
/**
@@ -223,7 +223,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setSortKey($sortKey)
{
$this->_sortKey = $sortKey;
$this->sortKey = $sortKey;
return $this;
}
@@ -235,7 +235,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getLimitStart()
{
return $this->_limitStart;
return $this->limitStart;
}
/**
@@ -247,7 +247,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setLimitStart($limitStart)
{
$this->_limitStart = $limitStart;
$this->limitStart = $limitStart;
return $this;
}
@@ -259,7 +259,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getLimitCount()
{
return $this->_limitCount;
return $this->limitCount;
}
/**
@@ -271,7 +271,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setLimitCount($limitCount)
{
$this->_limitCount = $limitCount;
$this->limitCount = $limitCount;
return $this;
}
@@ -283,7 +283,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getFirstPage()
{
return ceil(($this->_limitStart + 1) / $this->_limitCount);
return ceil(($this->limitStart + 1) / $this->limitCount);
}
/**
@@ -293,7 +293,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getLastPage()
{
return ceil($this->_totalRows / $this->_limitCount);
return ceil($this->totalRows / $this->limitCount);
}
/**
@@ -303,7 +303,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getTotalRows()
{
return $this->_totalRows;
return $this->totalRows;
}
/**
@@ -315,7 +315,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setTotalRows($totalRows)
{
$this->_totalRows = $totalRows;
$this->totalRows = $totalRows;
return $this;
}
@@ -327,7 +327,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getFilterOn()
{
return $this->_filterOn;
return $this->filterOn;
}
/**
@@ -339,7 +339,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setFilterOn($filterOn)
{
$this->_filterOn = $filterOn;
$this->filterOn = $filterOn;
return $this;
}
@@ -353,7 +353,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setOnClickFunction($function)
{
$this->_onClickFunction = $function;
$this->onClickFunction = $function;
return $this;
}
@@ -367,7 +367,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
{
$args = $this->parseArgs();
return count($args) > 0 ? $this->_onClickFunction . '(' . implode(',', $args) . ')' : $this->_onClickFunction;
return count($args) > 0 ? $this->onClickFunction . '(' . implode(',', $args) . ')' : $this->onClickFunction;
}
/**
@@ -377,7 +377,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
{
$args = array();
foreach ($this->_onClickArgs as $arg) {
foreach ($this->onClickArgs as $arg) {
$args[] = (!is_numeric($arg) && $arg !== 'this') ? '\'' . $arg . '\'' : $arg;
}
@@ -393,7 +393,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setOnClickArgs($args)
{
$this->_onClickArgs[] = $args;
$this->onClickArgs[] = $args;
return $this;
}
@@ -408,7 +408,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
$args = $this->parseArgs();
$args[] = $this->getFirst();
return $this->_onClickFunction . '(' . implode(',', $args) . ')';
return $this->onClickFunction . '(' . implode(',', $args) . ')';
}
/**
@@ -429,7 +429,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
$args = $this->parseArgs();
$args[] = $this->getLast();
return $this->_onClickFunction . '(' . implode(',', $args) . ')';
return $this->onClickFunction . '(' . implode(',', $args) . ')';
}
/**
@@ -437,7 +437,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getLast()
{
return (($this->_totalRows % $this->_limitCount) == 0) ? $this->_totalRows - $this->_limitCount : floor($this->_totalRows / $this->_limitCount) * $this->_limitCount;
return (($this->totalRows % $this->limitCount) == 0) ? $this->totalRows - $this->limitCount : floor($this->totalRows / $this->limitCount) * $this->limitCount;
}
/**
@@ -450,7 +450,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
$args = $this->parseArgs();
$args[] = $this->getNext();
return $this->_onClickFunction . '(' . implode(',', $args) . ')';
return $this->onClickFunction . '(' . implode(',', $args) . ')';
}
/**
@@ -458,7 +458,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getNext()
{
return ($this->_limitStart + $this->_limitCount);
return ($this->limitStart + $this->limitCount);
}
/**
@@ -471,7 +471,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
$args = $this->parseArgs();
$args[] = $this->getPrev();
return $this->_onClickFunction . '(' . implode(',', $args) . ')';
return $this->onClickFunction . '(' . implode(',', $args) . ')';
}
/**
@@ -479,7 +479,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getPrev()
{
return ($this->_limitStart - $this->_limitCount);
return ($this->limitStart - $this->limitCount);
}
/**
@@ -487,7 +487,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function getSourceAction()
{
return $this->_sourceAction;
return $this->sourceAction;
}
/**
@@ -497,7 +497,7 @@ abstract class DataGridPagerBase implements DataGridPagerInterface
*/
public function setSourceAction($sourceAction)
{
$this->_sourceAction = $sourceAction;
$this->sourceAction = $sourceAction;
return $this;
}

View File

@@ -38,34 +38,34 @@ final class DataGridSort implements DataGridSortInterface
/**
* @var int
*/
private $_sortKey = 0;
private $sortKey = 0;
/**
* @var string
*/
private $_title = '';
private $title = '';
/**
* @var string
*/
private $_name = '';
private $name = '';
/**
* @var array
*/
private $_class = array();
private $class = array();
/**
* @var IconInterface
*/
private $_iconUp;
private $iconUp;
/**
* @var IconInterface
*/
private $_iconDown;
private $iconDown;
/**
* @return int
*/
public function getSortKey()
{
return $this->_sortKey;
return $this->sortKey;
}
/**
@@ -75,7 +75,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function setSortKey($key)
{
$this->_sortKey = $key;
$this->sortKey = $key;
return $this;
}
@@ -85,7 +85,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function getTitle()
{
return $this->_title;
return $this->title;
}
/**
@@ -95,7 +95,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function setTitle($title)
{
$this->_title = $title;
$this->title = $title;
return $this;
}
@@ -105,7 +105,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function getName()
{
return $this->_name;
return $this->name;
}
/**
@@ -115,7 +115,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function setName($name)
{
$this->_name = $name;
$this->name = $name;
return $this;
}
@@ -125,7 +125,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function getClass()
{
return implode(' ', $this->_class);
return implode(' ', $this->class);
}
/**
@@ -135,7 +135,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function setClass($class)
{
$this->_class[] = $class;
$this->class[] = $class;
return $this;
}
@@ -145,7 +145,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function getIconUp()
{
return $this->_iconUp;
return $this->iconUp;
}
/**
@@ -155,7 +155,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function setIconUp(IconInterface $icon)
{
$this->_iconUp = $icon;
$this->iconUp = $icon;
return $this;
}
@@ -165,7 +165,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function getIconDown()
{
return $this->_iconDown;
return $this->iconDown;
}
/**
@@ -175,7 +175,7 @@ final class DataGridSort implements DataGridSortInterface
*/
public function setIconDown(IconInterface $icon)
{
$this->_iconDown = $icon;
$this->iconDown = $icon;
return $this;
}

View File

@@ -38,14 +38,14 @@ final class DataGridTab extends DataGridBase
*
* @var string
*/
private $_title = '';
private $title = '';
/**
* @return string
*/
public function getTitle()
{
return $this->_title;
return $this->title;
}
/**
@@ -55,7 +55,7 @@ final class DataGridTab extends DataGridBase
*/
public function setTitle($title)
{
$this->_title = $title;
$this->title = $title;
return $this;
}

View File

@@ -25,9 +25,7 @@
namespace SP\Html;
use Klein\Klein;
use SP\Core\Exceptions\SPException;
use SP\Http\Request;
use SP\Util\Util;
defined('APP_ROOT') || die();
@@ -116,11 +114,9 @@ final class Minify
// Obtener el recurso desde una URL
if ($file['type'] === 'url') {
try {
$data .= '/* URL: ' . $file['name'] . ' */' . PHP_EOL . Util::getDataFromUrl($file['name']);
} catch (SPException $e) {
processException($e);
}
logger('URL:' . $file['name']);
// $data .= '/* URL: ' . $file['name'] . ' */' . PHP_EOL . Util::getDataFromUrl($file['name']);
} else {
if ($file['min'] === true && $disableMinify === false) {
$data .= '/* MINIFIED FILE: ' . $file['name'] . ' */' . PHP_EOL;

View File

@@ -32,7 +32,7 @@ use SP\DataModel\ItemPreset\Password;
*
* @package SP\Mvc\Controller
*/
class PasswordValidator implements ValidatorInterface
final class PasswordValidator implements ValidatorInterface
{
/**
* @var Password

View File

@@ -29,7 +29,7 @@ namespace SP\Mvc\Controller\Validators;
*
* @package SP\Util
*/
class Validator
final class Validator
{
/**
* @param string $string

View File

@@ -32,7 +32,7 @@ use SP\Mvc\View\Template;
*
* @package SP\Mvc\View\Components
*/
class DataTab
final class DataTab
{
/**
* @var string

View File

@@ -29,7 +29,7 @@ namespace SP\Mvc\View\Components;
*
* @package SP\Mvc\View\Components
*/
class SelectItem
final class SelectItem
{
/**
* @var int

View File

@@ -33,7 +33,7 @@ use SP\Http\Json;
*
* @package SP\Mvc\View\Components
*/
class SelectItemAdapter implements ItemAdapterInterface
final class SelectItemAdapter implements ItemAdapterInterface
{
/**
* @var array

View File

@@ -26,8 +26,8 @@ namespace SP\Providers\Mail;
use DI\Container;
use PHPMailer\PHPMailer\PHPMailer;
use SP\Core\AppInfoInterface;
use SP\Providers\Provider;
use SP\Util\Util;
/**
* Class MailProvider
@@ -55,7 +55,7 @@ final class MailProvider extends Provider
*/
public function getMailer(MailParams $mailParams)
{
$appName = Util::getAppInfo('appname');
$appName = AppInfoInterface::APP_NAME;
try {
$this->mailer->SMTPAutoTLS = false;

View File

@@ -31,7 +31,7 @@ use SP\Core\Acl\Acl;
*
* @package SP\Account
*/
class AccountAcl
final class AccountAcl
{
/**
* @var bool

View File

@@ -37,7 +37,7 @@ use SP\Services\ItemPreset\ItemPresetService;
*
* @package SP\Services\Account
*/
class AccountPresetService
final class AccountPresetService
{
/**
* @var ItemPresetService

View File

@@ -29,7 +29,7 @@ namespace SP\Services\Account;
*
* @package SP\Account
*/
class AccountRequest
final class AccountRequest
{
/**
* @var int

View File

@@ -25,6 +25,7 @@
namespace SP\Services\Backup;
use SP\Config\ConfigData;
use SP\Core\AppInfoInterface;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\SPException;
@@ -36,7 +37,6 @@ use SP\Storage\Database\DatabaseUtil;
use SP\Storage\Database\QueryData;
use SP\Storage\File\FileHandler;
use SP\Util\Checks;
use SP\Util\Util;
defined('APP_ROOT') || die();
@@ -80,13 +80,11 @@ final class FileBackupService extends Service
$this->checkBackupDir();
$siteName = Util::getAppInfo('appname');
// Generar hash unico para evitar descargas no permitidas
$backupUniqueHash = sha1(uniqid('sysPassBackup', true));
$this->backupFileApp = $this->path . DIRECTORY_SEPARATOR . $siteName . '-' . $backupUniqueHash . '.tar';
$this->backupFileDb = $this->path . DIRECTORY_SEPARATOR . $siteName . '_db-' . $backupUniqueHash . '.sql';
$this->backupFileApp = $this->path . DIRECTORY_SEPARATOR . AppInfoInterface::APP_NAME . '-' . $backupUniqueHash . '.tar';
$this->backupFileDb = $this->path . DIRECTORY_SEPARATOR . AppInfoInterface::APP_NAME . '_db-' . $backupUniqueHash . '.sql';
try {
$this->deleteOldBackups();

View File

@@ -24,6 +24,7 @@
namespace SP\Services\Crypt;
use SP\Core\AppInfoInterface;
use SP\Core\Crypt\Crypt;
use SP\Core\Crypt\Hash;
use SP\Core\Events\Event;
@@ -209,7 +210,7 @@ final class TemporaryMasterPassService extends Service
private function getMessageForEmail($key)
{
$mailMessage = new MailMessage();
$mailMessage->setTitle(sprintf(__('Clave Maestra %s'), Util::getAppInfo('appname')));
$mailMessage->setTitle(sprintf(__('Clave Maestra %s'), AppInfoInterface::APP_NAME));
$mailMessage->addDescription(__('Se ha generado una nueva clave para el acceso a sysPass y se solicitará en el siguiente inicio.'));
$mailMessage->addDescriptionLine();
$mailMessage->addDescription(sprintf(__('La nueva clave es: %s'), $key));

View File

@@ -28,6 +28,7 @@ use DOMXPath;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use SP\Config\ConfigData;
use SP\Core\AppInfoInterface;
use SP\Core\Crypt\Crypt;
use SP\Core\Crypt\Hash;
use SP\Core\Events\Event;
@@ -40,7 +41,6 @@ use SP\Services\Client\ClientService;
use SP\Services\Service;
use SP\Services\ServiceException;
use SP\Services\Tag\TagService;
use SP\Util\Util;
use SP\Util\Version;
defined('APP_ROOT') || die();
@@ -129,7 +129,7 @@ final class XmlExportService extends Service
$this->configData->setExportHash($exportUniqueHash);
$this->config->saveConfig($this->configData);
return $this->exportPath . DIRECTORY_SEPARATOR . Util::getAppInfo('appname') . '-' . $exportUniqueHash . '.xml';
return $this->exportPath . DIRECTORY_SEPARATOR . AppInfoInterface::APP_NAME . '-' . $exportUniqueHash . '.xml';
}
/**

View File

@@ -57,7 +57,7 @@ final class Installer extends Service
*/
const VERSION = [3, 0, 0];
const VERSION_TEXT = '3.0-beta';
const BUILD = 18093001;
const BUILD = 18100101;
/**
* @var DatabaseSetupInterface

View File

@@ -32,7 +32,7 @@ use SP\DataModel\ItemPresetData;
*
* @package SP\Services\ItemPreset
*/
class ItemPresetRequest
final class ItemPresetRequest
{
/**
* @var ItemPresetData

View File

@@ -37,7 +37,7 @@ use SP\Storage\Database\QueryResult;
*
* @package SP\Services\Account
*/
class ItemPresetService extends Service
final class ItemPresetService extends Service
{
/**
* @var ItemPresetRepository

View File

@@ -26,6 +26,7 @@ namespace SP\Services\Mail;
use PHPMailer\PHPMailer\PHPMailer;
use SP\Bootstrap;
use SP\Core\AppInfoInterface;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\Messages\MailMessage;
@@ -35,7 +36,6 @@ use SP\Providers\Mail\MailProvider;
use SP\Providers\Mail\MailProviderException;
use SP\Services\Service;
use SP\Services\ServiceException;
use SP\Util\Util;
/**
* Class MailService
@@ -48,10 +48,6 @@ final class MailService extends Service
* @var PHPMailer
*/
protected $mailer;
/**
* @var array
*/
private $appInfo;
/**
* Checks mail params by sending a test email
@@ -100,7 +96,7 @@ final class MailService extends Service
return [
'',
'--',
sprintf('%s - %s', $this->appInfo['appname'], $this->appInfo['appdesc']),
sprintf('%s - %s', AppInfoInterface::APP_NAME, AppInfoInterface::APP_DESC),
Html::anchorText(Bootstrap::$WEBURI)
];
}
@@ -112,7 +108,7 @@ final class MailService extends Service
*/
protected function getSubjectForAction($action)
{
return sprintf('%s - %s', $this->appInfo['appname'], $action);
return sprintf('%s - %s', AppInfoInterface::APP_NAME, $action);
}
/**
@@ -189,8 +185,6 @@ final class MailService extends Service
} else {
throw new ServiceException(__u('Servicio de correo no disponible'));
}
$this->appInfo = Util::getAppInfo();
}
/**

View File

@@ -36,7 +36,7 @@ use SP\Services\Service;
*
* @package SP\Services\Upgrade
*/
class UpgradeAuthToken extends Service
final class UpgradeAuthToken extends Service
{
/**
* @var AuthTokenService

View File

@@ -38,7 +38,7 @@ use SP\Storage\Database\QueryData;
*
* @package SP\Services\Upgrade
*/
class UpgradeCustomFieldData extends Service
final class UpgradeCustomFieldData extends Service
{
/**
* @var Database

View File

@@ -22,19 +22,17 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Util\Wiki;
namespace SP\Services\Wiki;
use SP\Core\Exceptions\SPException;
use SP\Core\SessionFactory;
use SP\Log\Log;
use SP\Log\LogLevel;
defined('APP_ROOT') || die();
/**
* Class DokuWikiApi para realizar consultas a la API de DokuWiki
*
* @package SP\Util\Wiki
* @package SP\Services\Wiki
* @deprecated
*/
class DokuWikiApi extends DokuWikiApiBase
{
@@ -76,7 +74,6 @@ class DokuWikiApi extends DokuWikiApiBase
$this->logException($e);
throw $e;
} catch (\InvalidArgumentException $e) {
Log::writeNewLog('DokuWiki API', $e->getMessage(), LogLevel::ERROR);
throw new SPException($e->getMessage(), SPException::WARNING);
}
}

View File

@@ -22,10 +22,9 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Util\Wiki;
namespace SP\Services\Wiki;
use DOMDocument;
use DOMException;
use SP\Config\Config;
use SP\Config\ConfigData;
use SP\Core\Exceptions\SPException;
@@ -35,7 +34,8 @@ use SP\Util\Util;
/**
* Class DokuWikiApiBase
*
* @package SP\Util\Wiki
* @package SP\Services\Wiki
* @deprecated
*/
abstract class DokuWikiApiBase
{
@@ -130,7 +130,7 @@ abstract class DokuWikiApiBase
$this->params = $this->xml->createElement('params');
$this->root->appendChild($this->params);
} catch (DOMException $e) {
} catch (\Exception $e) {
throw new SPException($e->getMessage(), SPException::WARNING, __FUNCTION__);
}
}
@@ -158,13 +158,15 @@ abstract class DokuWikiApiBase
$xmlParam->appendChild($xmlValue);
$this->params->appendChild($xmlParam);
} catch (DOMException $e) {
} catch (\Exception $e) {
throw new SPException($e->getMessage(), SPException::WARNING, __FUNCTION__);
}
}
/**
* Enviar el XML a la wiki y devolver la respuesta
*
* @throws SPException
*/
protected function callWiki()
{

View File

@@ -22,14 +22,15 @@
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Util\Wiki;
namespace SP\Services\Wiki;
use SP\Http\XMLRPCResponseParse;
/**
* Class DokuWikiApiParse para el parseo de las respuestas de DokuWiki
*
* @package SP\Util\Wiki
* @package SP\Services\Wiki
* @deprecated
*/
class DokuWikiApiParse extends XMLRPCResponseParse
{

View File

@@ -26,10 +26,6 @@ namespace SP\Util;
use Defuse\Crypto\Core;
use Defuse\Crypto\Encoding;
use SP\Bootstrap;
use SP\Config\ConfigData;
use SP\Core\Exceptions\SPException;
use SP\Core\PhpExtensionChecker;
defined('APP_ROOT') || die();
@@ -125,102 +121,6 @@ final class Util
return Encoding::binToHex(Core::secureRandom($length));
}
/**
* Obtener datos desde una URL usando CURL
*
* @param string $url
* @param array $data
* @param bool|null $useCookie
* @param bool $weak
*
* @return bool|string
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
*
* TODO: Use Guzzle
*
* @throws \SP\Core\Exceptions\CheckException
* @throws SPException
*/
public static function getDataFromUrl($url, array $data = null, $useCookie = false, $weak = false)
{
/** @var ConfigData $ConfigData */
$ConfigData = Bootstrap::getContainer()->get(ConfigData::class);
Bootstrap::getContainer()->get(PhpExtensionChecker::class)->checkCurlAvailable(true);
$ch = curl_init($url);
if ($ConfigData->isProxyEnabled()) {
curl_setopt($ch, CURLOPT_PROXY, $ConfigData->getProxyServer());
curl_setopt($ch, CURLOPT_PROXYPORT, $ConfigData->getProxyPort());
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
$proxyUser = $ConfigData->getProxyUser();
if ($proxyUser) {
$proxyAuth = $proxyUser . ':' . $ConfigData->getProxyPass();
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth);
}
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'sysPass-App');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
if ($weak === true) {
// Trust SSL enabled server
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
}
if (null !== $data) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $data['type']);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data['data']);
}
if ($useCookie) {
$cookie = self::getUserCookieFile();
if ($cookie) {
if (!SessionFactory::getCurlCookieSession()) {
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
SessionFactory::setCurlCookieSession(true);
}
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
}
}
$data = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($data === false || $httpStatus !== 200) {
throw new SPException(curl_error($ch), SPException::WARNING);
}
return $data;
}
/**
* Devuelve el nombre de archivo a utilizar para las cookies del usuario
*
* @return string|false
*/
public static function getUserCookieFile()
{
$tempDir = self::getTempDir();
return $tempDir ? $tempDir . DIRECTORY_SEPARATOR . md5('syspass-' . SessionFactory::getUserData()->getLogin()) : false;
}
/**
* Comprueba y devuelve un directorio temporal válido
*
@@ -253,35 +153,6 @@ final class Util
return $checkDir($sysTmp);
}
/**
* Devuelve información sobre la aplicación.
*
* @param string $index con la key a devolver
*
* @return array|string con las propiedades de la aplicación
*/
public static function getAppInfo($index = null)
{
$appinfo = [
'appname' => 'sysPass',
'appdesc' => 'Systems Password Manager',
'appalias' => 'SPM',
'appwebsite' => 'https://www.syspass.org',
'appblog' => 'https://www.cygnux.org',
'appdoc' => 'https://doc.syspass.org',
'appupdates' => 'https://api.github.com/repos/nuxsmin/sysPass/releases/latest',
'appnotices' => 'https://api.github.com/repos/nuxsmin/sysPass/issues?milestone=none&state=open&labels=Notices',
'apphelp' => 'https://github.com/nuxsmin/sysPass/issues',
'appchangelog' => 'https://github.com/nuxsmin/sysPass/blob/master/CHANGELOG'
];
if (null !== $index && isset($appinfo[$index])) {
return $appinfo[$index];
}
return $appinfo;
}
/**
* Realiza el proceso de logout.
*

View File

@@ -31,9 +31,8 @@ use SP\Services\Install\Installer;
*
* @package SP\Util
*/
class Version
final class Version
{
/**
* Devolver versión normalizada en cadena
*

View File

@@ -9,11 +9,11 @@
<authBasicAutoLoginEnabled>1</authBasicAutoLoginEnabled>
<authBasicDomain></authBasicDomain>
<authBasicEnabled>1</authBasicEnabled>
<backup_hash>31886087e728255b01dbce0c08ff2e54b5b633e2</backup_hash>
<backup_hash>998778b76a94725b950613dbf4cc45a81acd0fc2</backup_hash>
<checkUpdates>0</checkUpdates>
<checknotices>0</checknotices>
<configDate>1538352842</configDate>
<configHash>c82c662c26a397798f8bf984cf5492c890571974</configHash>
<configDate>1538433038</configDate>
<configHash>ce2dd4ecc25c80c9a1fbdbaf4f932a1f6d1be7de</configHash>
<configSaver></configSaver>
<configVersion></configVersion>
<databaseVersion></databaseVersion>
@@ -32,7 +32,7 @@
<dokuwikiUrlBase></dokuwikiUrlBase>
<dokuwikiUser></dokuwikiUser>
<encryptSession>0</encryptSession>
<export_hash>aab488455bd1e70816a491b44b1be68f34e79618</export_hash>
<export_hash>5befe3b5fbc6188557ca44037ebaf5071842875a</export_hash>
<filesAllowedExts>
<item type="filesAllowedExts">PDF</item>
<item type="filesAllowedExts">JPG</item>