mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-12 03:16:54 +01:00
* [DEV] DB usage refactoring
* [DEV] Fixed public links issue
This commit is contained in:
@@ -612,12 +612,10 @@ class Account extends AccountBase implements AccountInterface
|
||||
$query = /** @lang SQL */
|
||||
'SELECT account_id, account_name, account_pass, account_IV FROM accounts';
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,15 +50,9 @@ class AccountFavorites
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($userId, 'userId');
|
||||
|
||||
DB::setReturnArray();
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false){
|
||||
return array();
|
||||
}
|
||||
|
||||
$favorites = array();
|
||||
$favorites = [];
|
||||
|
||||
foreach($queryRes as $favorite){
|
||||
$favorites[] = $favorite->accfavorite_accountId;
|
||||
|
||||
@@ -70,15 +70,9 @@ class AccountHistory extends AccountBase implements AccountInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($accountId, 'id');
|
||||
|
||||
DB::setReturnArray();
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$arrHistory = array();
|
||||
$arrHistory = [];
|
||||
|
||||
foreach ($queryRes as $history) {
|
||||
// Comprobamos si la entrada en el historial es la primera (no tiene editor ni fecha de edición)
|
||||
@@ -234,9 +228,7 @@ class AccountHistory extends AccountBase implements AccountInterface
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -454,18 +454,11 @@ class AccountSearch
|
||||
// Obtener el número total de cuentas visibles por el usuario
|
||||
DB::setFullRowCount();
|
||||
|
||||
// Obtener los resultados siempre en array de objetos
|
||||
DB::setReturnArray();
|
||||
|
||||
// Log::writeNewLog(__FUNCTION__, $Data->getQuery(), Log::DEBUG);
|
||||
// Log::writeNewLog(__FUNCTION__, print_r($Data->getParams(), true), Log::DEBUG);
|
||||
|
||||
// Consulta de la búsqueda de cuentas
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return false;
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
// Obtenemos el número de registros totales de la consulta sin contar el LIMIT
|
||||
self::$queryNumRows = $Data->getQueryNumRows();
|
||||
|
||||
@@ -60,9 +60,7 @@ class AccountTags
|
||||
$Data->setUseKeyPair(true);
|
||||
$Data->addParam($accountData->getAccountId(), 'id');
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -126,11 +126,9 @@ class AccountUtil
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
try {
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
}catch (SPException $e) {
|
||||
throw new SPException(SPException::SP_CRITICAL, _('No se pudieron obtener los datos de las cuentas'));
|
||||
}
|
||||
|
||||
@@ -191,14 +189,9 @@ class AccountUtil
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
|
||||
@@ -133,11 +133,9 @@ class UserAccounts
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($accountId, 'id');
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$users = [];
|
||||
|
||||
foreach (DB::getResults($Data) as $user) {
|
||||
foreach (DB::getResultsArray($Data) as $user) {
|
||||
$users[] = (int)$user->accuser_userId;
|
||||
}
|
||||
|
||||
@@ -165,8 +163,6 @@ class UserAccounts
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($accountId, 'id');
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
}
|
||||
@@ -61,28 +61,22 @@ class ApiTokensUtil
|
||||
$Data = new QueryData();
|
||||
|
||||
if (!is_null($tokenId)) {
|
||||
$query .= "WHERE authtoken_id = :id LIMIT 1";
|
||||
$query .= 'WHERE authtoken_id = :id LIMIT 1';
|
||||
$Data->addParam($tokenId, 'id');
|
||||
} else {
|
||||
$query .= "ORDER BY user_login";
|
||||
$query .= 'ORDER BY user_login';
|
||||
}
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
if (!$returnRawData) {
|
||||
DB::setReturnArray();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$returnRawData) {
|
||||
foreach ($queryRes as &$token) {
|
||||
$token->authtoken_actionId = Acl::getActionName($token->authtoken_actionId);
|
||||
}
|
||||
} else {
|
||||
$queryRes = DB::getResults($Data);
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
@@ -120,14 +114,9 @@ class ApiTokensUtil
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
foreach ($queryRes as &$token) {
|
||||
$token->authtoken_actionId = Acl::getActionName($token->authtoken_actionId);
|
||||
|
||||
@@ -196,6 +196,8 @@ class AccItemController extends ControllerBase implements ActionsInterface
|
||||
$this->module = self::ACTION_MGM_PUBLICLINKS;
|
||||
$this->view->addTemplate('publiclinks');
|
||||
|
||||
$this->view->assign('link', PublicLink::getItem()->getById($this->view->itemId));
|
||||
$PublicLink = PublicLink::getItem();
|
||||
|
||||
$this->view->assign('link', $PublicLink->getItemForList($PublicLink->getById($this->view->itemId)));
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ use SP\Mgmt\Customers\Customer;
|
||||
use SP\Mgmt\Groups\Group;
|
||||
use SP\Mgmt\Groups\GroupAccountsUtil;
|
||||
use SP\Mgmt\CustomFields\CustomField;
|
||||
use SP\Mgmt\PublicLinks\PublicLink;
|
||||
use SP\Mgmt\Tags\Tag;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\SessionUtil;
|
||||
@@ -181,7 +182,9 @@ class AccountController extends ControllerBase implements ActionsInterface
|
||||
$this->view->assign('maxFileSize', round(Config::getConfig()->getFilesAllowedSize() / 1024, 1));
|
||||
$this->view->assign('filesAllowedExts', implode(',', Config::getConfig()->getFilesAllowedExts()));
|
||||
|
||||
$publicLinkUrl = (Checks::publicLinksIsEnabled() && $this->AccountData->getPublicLinkHash() ? Init::$WEBURI . '/?h=' . $this->AccountData->getPublicLinkHash() . '&a=link' : '');
|
||||
$PublicLinkData = PublicLink::getItem()->getHashForItem($this->getId());
|
||||
|
||||
$publicLinkUrl = (Checks::publicLinksIsEnabled() && $PublicLinkData ? Init::$WEBURI . '/?h=' . $PublicLinkData->getPublicLinkHash() . '&a=link' : '');
|
||||
$this->view->assign('publicLinkUrl', $publicLinkUrl);
|
||||
|
||||
$this->view->assign('accountPassDate', gmdate('Y-m-d H:i:s', $this->AccountData->getAccountPassDate()));
|
||||
@@ -488,14 +491,16 @@ class AccountController extends ControllerBase implements ActionsInterface
|
||||
);
|
||||
$this->Account->incrementViewCounter();
|
||||
$this->Account->incrementDecryptCounter();
|
||||
$this->Account->getAccountPassData();
|
||||
$AccountPassData = $this->Account->getAccountPassData();
|
||||
|
||||
// Desencriptar la clave de la cuenta
|
||||
$pass = Crypt::generateAesKey($PublicLinkData->getLinkHash());
|
||||
$masterPass = Crypt::getDecrypt($PublicLinkData->getPass(), $PublicLinkData->getPassIV(), $pass);
|
||||
$accountPass = Crypt::getDecrypt($this->Account->getAccountData()->getAccountPass(), $this->Account->getAccountData()->getAccountIV(), $masterPass);
|
||||
$accountPass = Crypt::getDecrypt($AccountPassData->pass, $AccountPassData->iv, $masterPass);
|
||||
|
||||
if (Config::getConfig()->isPublinksImageEnabled()) {
|
||||
$this->view->assign('useImage', Config::getConfig()->isPublinksImageEnabled());
|
||||
|
||||
if ($this->view->useImage) {
|
||||
$accountPass = ImageUtil::convertText($accountPass);
|
||||
}
|
||||
|
||||
|
||||
@@ -478,23 +478,24 @@ class ItemActionController
|
||||
protected function publicLinkAction()
|
||||
{
|
||||
$PublicLinkData = new PublicLinkData();
|
||||
$PublicLinkData->setItemId($this->itemId);
|
||||
$PublicLinkData->setPublicLinkItemId($this->itemId);
|
||||
$PublicLinkData->setTypeId(PublicLink::TYPE_ACCOUNT);
|
||||
$PublicLinkData->setNotify(Request::analyze('notify', false, false, true));
|
||||
|
||||
switch ($this->actionId) {
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_NEW:
|
||||
$PublicLinkData->setItemId($this->itemId);
|
||||
PublicLink::getItem($PublicLinkData)->add();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Enlace creado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_REFRESH:
|
||||
PublicLink::getItem($PublicLinkData)->update();
|
||||
PublicLink::getItem(PublicLink::getItem()->getById($this->itemId))->refresh();
|
||||
|
||||
$this->jsonResponse->setDescription(_('Enlace actualizado'));
|
||||
break;
|
||||
case ActionsInterface::ACTION_MGM_PUBLICLINKS_DELETE:
|
||||
PublicLink::getItem()->delete($PublicLinkData->getId());
|
||||
PublicLink::getItem()->delete($this->itemId);
|
||||
|
||||
$this->jsonResponse->setDescription(_('Enlace eliminado'));
|
||||
break;
|
||||
|
||||
@@ -137,12 +137,10 @@ class Backup
|
||||
$sqlOut .= $txtCreate->{'Create Table'} . ';' . PHP_EOL . PHP_EOL;
|
||||
fwrite($handle, $sqlOut);
|
||||
|
||||
DB::setReturnRawData();
|
||||
|
||||
$Data->setQuery('SELECT * FROM ' . $tableName);
|
||||
|
||||
// Consulta para obtener los registros de la tabla
|
||||
$queryRes = DB::getResults($Data);
|
||||
$queryRes = DB::getResultsRaw($Data);
|
||||
|
||||
$numColumns = $queryRes->columnCount();
|
||||
|
||||
@@ -165,9 +163,8 @@ class Backup
|
||||
}
|
||||
fwrite($handle, ');' . PHP_EOL);
|
||||
}
|
||||
fwrite($handle, PHP_EOL . PHP_EOL);
|
||||
|
||||
DB::setReturnRawData(false);
|
||||
fwrite($handle, PHP_EOL . PHP_EOL);
|
||||
}
|
||||
|
||||
$sqlOut = '--' . PHP_EOL;
|
||||
|
||||
@@ -31,7 +31,6 @@ use SP\Config\ConfigDB;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Log\Log;
|
||||
use SP\Util\Checks;
|
||||
use SP\Util\Util;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
@@ -64,9 +63,7 @@ class Crypt
|
||||
*/
|
||||
public static function makeHashSalt()
|
||||
{
|
||||
$salt = '$2y$07$' . bin2hex(self::getIV()) . '$';
|
||||
|
||||
return $salt;
|
||||
return '$2y$07$' . bin2hex(self::getIV()) . '$';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +120,7 @@ class Crypt
|
||||
|
||||
// Comprobar si el hash está en formato anterior a 12002
|
||||
if ($isMPass && strlen($checkedHash) === 128) {
|
||||
$check = (hash("sha256", substr($checkedHash, 0, 64) . $pwd) == substr($checkedHash, 64, 64));
|
||||
$check = (hash('sha256', substr($checkedHash, 0, 64) . $pwd) === substr($checkedHash, 64, 64));
|
||||
|
||||
if ($check) {
|
||||
$newHash = self::mkHashPassword($pwd);
|
||||
@@ -137,7 +134,7 @@ class Crypt
|
||||
}
|
||||
|
||||
// Si los hashes son idénticos, la clave es válida
|
||||
return $testHash == $validHash;
|
||||
return $testHash === $validHash;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,9 +148,8 @@ class Crypt
|
||||
{
|
||||
$cryptIV = self::getIV();
|
||||
$cryptValue = self::encrypt($masterPwd, $customPwd, $cryptIV);
|
||||
$dataCrypt = array($cryptValue, $cryptIV);
|
||||
|
||||
return $dataCrypt;
|
||||
return [$cryptValue, $cryptIV];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +230,7 @@ class Crypt
|
||||
*/
|
||||
public static function mkEncrypt($data, $masterPwd = null)
|
||||
{
|
||||
$masterPwd = (is_null($masterPwd)) ? SessionUtil::getSessionMPass() : $masterPwd;
|
||||
$masterPwd = null === $masterPwd ? SessionUtil::getSessionMPass() : $masterPwd;
|
||||
|
||||
self::$strInitialVector = self::getIV();
|
||||
$cryptValue = self::encrypt($data, $masterPwd, self::$strInitialVector);
|
||||
@@ -256,7 +252,7 @@ class Crypt
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_null($password)) {
|
||||
if (null === $password) {
|
||||
$password = SessionUtil::getSessionMPass();
|
||||
// self::getSessionMasterPass();
|
||||
}
|
||||
@@ -280,14 +276,13 @@ class Crypt
|
||||
*/
|
||||
public static function generateAesKey($string, $salt = null)
|
||||
{
|
||||
if (is_null($salt)) {
|
||||
if (null === $salt) {
|
||||
$salt = Config::getConfig()->getPasswordSalt();
|
||||
}
|
||||
|
||||
$salt = '$2y$07$' . $salt . '$';
|
||||
$key = substr(crypt($string, $salt), 7, 32);
|
||||
|
||||
return $key;
|
||||
return substr(crypt($string, $salt), 7, 32);
|
||||
}
|
||||
|
||||
public static function checkPassword($pwd, $salt)
|
||||
|
||||
@@ -55,7 +55,7 @@ class SPException extends Exception
|
||||
* SPException constructor.
|
||||
*
|
||||
* @param string $type
|
||||
* @param int $message
|
||||
* @param string $message
|
||||
* @param string $hint
|
||||
* @param int $code
|
||||
* @param Exception|null $previous
|
||||
|
||||
@@ -34,6 +34,10 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
|
||||
*/
|
||||
class PublicLinkBaseData extends DataModelBase
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $publicLink_id = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
@@ -50,17 +54,17 @@ class PublicLinkBaseData extends DataModelBase
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPublicLinkItemId()
|
||||
public function getPublicLinkId()
|
||||
{
|
||||
return $this->publicLink_itemId;
|
||||
return (int)$this->publicLink_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $publicLink_itemId
|
||||
* @param int $publicLink_id
|
||||
*/
|
||||
public function setPublicLinkItemId($publicLink_itemId)
|
||||
public function setPublicLinkId($publicLink_id)
|
||||
{
|
||||
$this->publicLink_itemId = $publicLink_itemId;
|
||||
$this->publicLink_id = (int)$publicLink_id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,4 +98,20 @@ class PublicLinkBaseData extends DataModelBase
|
||||
{
|
||||
$this->publicLink_linkData = $publicLink_linkData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPublicLinkItemId()
|
||||
{
|
||||
return (int)$this->publicLink_itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $publicLink_itemId
|
||||
*/
|
||||
public function setPublicLinkItemId($publicLink_itemId)
|
||||
{
|
||||
$this->publicLink_itemId = (int)$publicLink_itemId;
|
||||
}
|
||||
}
|
||||
@@ -1,970 +0,0 @@
|
||||
<?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\Import;
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\DataModel\CategoryData;
|
||||
use SP\Mgmt\Customers\Customer;
|
||||
use SP\Log\Log;
|
||||
use SP\Core\Session;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Storage\DB;
|
||||
use SP\Storage\DBUtil;
|
||||
use SP\Storage\QueryData;
|
||||
|
||||
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
|
||||
|
||||
/**
|
||||
* Esta clase es la encargada de realizar la migración de datos desde phpPMS.
|
||||
*/
|
||||
class Migrate
|
||||
{
|
||||
private static $DB; // Database connection
|
||||
private static $customersByName;
|
||||
private static $currentQuery;
|
||||
private static $result = array();
|
||||
private static $oldConfig = array();
|
||||
|
||||
/**
|
||||
* Iniciar migración desde phpPMS.
|
||||
*
|
||||
* @param array $options datos de conexión
|
||||
* @return array resultado del proceso
|
||||
*/
|
||||
public static function migrate($options)
|
||||
{
|
||||
|
||||
if (!is_array($options)) {
|
||||
$result['error'][]['description'] = _('Faltan parámetros');
|
||||
return $result;
|
||||
}
|
||||
|
||||
$dbname = $options['dbname'];
|
||||
|
||||
if (preg_match('/(.*):(\d{1,5})/', $options['dbhost'], $match)){
|
||||
$dbhost = $match[1];
|
||||
$dbport = $match[2];
|
||||
} else {
|
||||
$dbhost = $options['dbhost'];
|
||||
$dbport = 3306;
|
||||
}
|
||||
|
||||
$dbadmin = $options['dbuser'];
|
||||
$dbpass = $options['dbpass'];
|
||||
|
||||
try {
|
||||
self::checkDatabaseAdmin($dbhost, $dbadmin, $dbpass, $dbname, $dbport);
|
||||
self::checkDatabaseExist($dbname);
|
||||
self::checkSourceVersion();
|
||||
self::cleanCurrentDB();
|
||||
self::migrateCustomers();
|
||||
self::migrateAccounts();
|
||||
self::migrateAccountsGroups();
|
||||
self::migrateAccountsHistory();
|
||||
self::migrateAcountsFiles();
|
||||
self::migrateAccountsCategories();
|
||||
self::migrateUsers();
|
||||
self::migrateUsersGroups();
|
||||
self::migrateConfig();
|
||||
} catch (SPException $e) {
|
||||
self::$result['error'][] = array(
|
||||
'type' => $e->getType(),
|
||||
'description' => $e->getMessage(),
|
||||
'hint' => $e->getHint()
|
||||
);
|
||||
return (self::$result);
|
||||
}
|
||||
|
||||
self::$result['ok'][] = _('Importación finalizada');
|
||||
self::$result['ok'][] = _('Revise el registro de eventos para más detalles');
|
||||
|
||||
return (self::$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si la conexión con la BBDD de phpPMS es posible.
|
||||
*
|
||||
* @param string $dbhost host de conexión
|
||||
* @param string $dbadmin usuario de conexión
|
||||
* @param string $dbpass clave de conexión
|
||||
* @param string $dbname nombre de la base de datos
|
||||
* @param string $dbport puerto de conexión
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
private static function checkDatabaseAdmin($dbhost, $dbadmin, $dbpass, $dbname, $dbport)
|
||||
{
|
||||
try {
|
||||
$dsn = 'mysql:host=' . $dbhost . ';dbname=' . $dbname . ';dbport=' . $dbport . ';charset=utf8';
|
||||
self::$DB = new \PDO($dsn, $dbadmin, $dbpass);
|
||||
} catch (\PDOException $e) {
|
||||
throw new SPException(SPException::SP_CRITICAL
|
||||
, _('No es posible conectar con la BD')
|
||||
, _('Compruebe los datos de conexión') . '<br>' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si la BBDD existe.
|
||||
*
|
||||
* @param string $dbname nombre de la base de datos
|
||||
* @return bool
|
||||
*/
|
||||
private static function checkDatabaseExist($dbname)
|
||||
{
|
||||
$query = 'SELECT COUNT(*) '
|
||||
. 'FROM information_schema.tables '
|
||||
. 'WHERE table_schema = \'' . $dbname . '\' '
|
||||
. 'AND table_name = \'usrData\' LIMIT 1';
|
||||
|
||||
return (intval(self::$DB->query($query)->fetchColumn()) === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar la versión de phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
private static function checkSourceVersion()
|
||||
{
|
||||
if (!isset(self::$oldConfig['version'])) {
|
||||
self::getSourceConfig();
|
||||
}
|
||||
|
||||
if (self::$oldConfig['version'] != "0.973b") {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('La versión no es compatible') . '(' . self::$oldConfig['version'] . ')',
|
||||
_('Actualice a la última versión de phpPMS'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener la configuración desde desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
private static function getSourceConfig()
|
||||
{
|
||||
$query = 'SELECT vacValue as value,vacParameter as parameter FROM config';
|
||||
|
||||
try {
|
||||
self::parseSourceConfig(self::$DB->query($query));
|
||||
} catch (\PDOException $e) {
|
||||
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al obtener la configuración'),
|
||||
$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsear los valores de configuración de phpPMS y adaptarlos a sysPass.
|
||||
*
|
||||
* @param array $config con los datos de configuración
|
||||
* @return bool
|
||||
*/
|
||||
private static function parseSourceConfig($config)
|
||||
{
|
||||
if (!is_array($config)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strtolower($config['value']) == 'true' || strtolower($config['value']) == 'on') {
|
||||
$value = 1;
|
||||
} else {
|
||||
$value = (is_numeric($config['value'])) ? (int)$config['value'] : trim($config['value']);
|
||||
}
|
||||
|
||||
// Guardar la configuración anterior
|
||||
self::$oldConfig[$config['parameter']] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limpiar los datos de sysPass.
|
||||
* Limpiar las tablas de la base de sysPass para la importación.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
private static function cleanCurrentDB()
|
||||
{
|
||||
$tables = array('accounts', 'accHistory', 'accFiles', 'accGroups', 'categories', 'customers', 'usrGroups');
|
||||
|
||||
// Limpiar datos de las tablas
|
||||
foreach ($tables as $table) {
|
||||
$query = 'TRUNCATE TABLE ' . $table;
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al vaciar tabla') . ' (' . $table . ')',
|
||||
DB::$txtError);
|
||||
}
|
||||
}
|
||||
|
||||
$currentUserId = Session::getUserId();
|
||||
|
||||
// Limpiar datos de usuarios manteniendo el usuario actual
|
||||
if (self::checkAdminAccount($currentUserId)) {
|
||||
$query = 'DELETE FROM usrData WHERE user_id != :userid';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($currentUserId, 'userid');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al vaciar tabla') . ' (' . $table . ')',
|
||||
DB::$txtError);
|
||||
}
|
||||
} else {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Usuario actual no es administrador de la aplicación'), 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprobar si el usuario actual es administrador de la aplicación.
|
||||
*
|
||||
* @param int $currentUserId con el Id del usuario de la sesión actual
|
||||
* @return bool
|
||||
*/
|
||||
private static function checkAdminAccount($currentUserId)
|
||||
{
|
||||
$query = 'SELECT user_id FROM usrData WHERE user_id = :id AND user_isAdminApp = 1 LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($currentUserId, 'id');
|
||||
|
||||
DB::getQuery($Data);
|
||||
|
||||
return ($Data->getQueryNumRows() === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrar los clientes desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return array resultado
|
||||
*/
|
||||
private static function migrateCustomers()
|
||||
{
|
||||
$customers = self::getCustomers();
|
||||
|
||||
$totalRecords = count($customers);
|
||||
$num = 0;
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
try {
|
||||
Customer::getItem(new CategoryData(null, $customer))->add();
|
||||
$num++;
|
||||
} catch (SPException $e) {
|
||||
if ($e->getType() === SPException::SP_WARNING){
|
||||
continue;
|
||||
}
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('No es posible crear el cliente'),
|
||||
_('Contacte con el desarrollador'));
|
||||
}
|
||||
}
|
||||
|
||||
$Log = new Log(_('Importar Clientes'));
|
||||
$Log->addDescription('OK');
|
||||
$Log->addDetails(_('Registros'), $num . '/' . $totalRecords);
|
||||
$Log->writeLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los clientes desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return array con los clientes
|
||||
*/
|
||||
private static function getCustomers()
|
||||
{
|
||||
$query = 'SELECT DISTINCT vacCliente FROM accounts';
|
||||
|
||||
try {
|
||||
foreach (self::$DB->query($query) as $row) {
|
||||
$customers[] = trim($row['vacCliente']);
|
||||
}
|
||||
|
||||
return $customers;
|
||||
} catch (\PDOException $e) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al obtener los clientes'),
|
||||
$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrar las cuentas desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return array resultado
|
||||
*/
|
||||
private static function migrateAccounts()
|
||||
{
|
||||
$query = 'SELECT intAccountId,'
|
||||
. 'intUGroupFId,'
|
||||
. 'intUserFId,'
|
||||
. 'intUEditFId,'
|
||||
. 'vacCliente,vacName,'
|
||||
. 'intCategoryFid,'
|
||||
. 'vacLogin,'
|
||||
. 'vacUrl,'
|
||||
. 'vacPassword,'
|
||||
. 'vacMd5Password,'
|
||||
. 'vacInitialValue,'
|
||||
. 'txtNotice,'
|
||||
. 'intCountView,'
|
||||
. 'intCountDecrypt,'
|
||||
. 'datAdded,datChanged '
|
||||
. 'FROM accounts ';
|
||||
|
||||
$totalRecords = 0;
|
||||
$num = 0;
|
||||
|
||||
try {
|
||||
foreach (self::$DB->query($query) as $row) {
|
||||
if (self::insertAccounts($row)) {
|
||||
$num++;
|
||||
}
|
||||
$totalRecords++;
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al obtener cuentas'),
|
||||
$e->getMessage());
|
||||
}
|
||||
|
||||
$Log = new Log(_('Importar Cuentas'));
|
||||
$Log->addDescription('OK');
|
||||
$Log->addDetails(_('Registros'), $num . '/' . $totalRecords);
|
||||
$Log->writeLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insertar una cuenta en sysPass.
|
||||
*
|
||||
* @param array $account con los datos de la cuenta
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return bool
|
||||
*/
|
||||
private static function insertAccounts($account)
|
||||
{
|
||||
// FIXME
|
||||
if (!is_array(self::$customersByName)) {
|
||||
$customers = Customer::getCustomers(NULL, true);
|
||||
self::$customersByName = array_flip($customers);
|
||||
}
|
||||
|
||||
$customer = trim($account['vacCliente']);
|
||||
|
||||
if (array_key_exists($customer, self::$customersByName)) {
|
||||
$customerId = self::$customersByName[$customer];
|
||||
} else {
|
||||
self::$result['error'][] = _('Cliente no encontrado') . ": " . $account['vacCliente'];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO accounts SET ' .
|
||||
'account_id = :id,' .
|
||||
'account_userGroupId = :userGroupId,' .
|
||||
'account_userId = :userId,' .
|
||||
'account_userEditId = :userEditId,' .
|
||||
'account_customerId = :customerId,' .
|
||||
'account_name = :name,' .
|
||||
'account_categoryId = :categoryId,' .
|
||||
'account_login = :login,' .
|
||||
'account_url = :url,' .
|
||||
'account_pass = :pass,' .
|
||||
'account_IV = :iv,' .
|
||||
'account_notes = :notes,' .
|
||||
'account_countView = :countView,' .
|
||||
'account_countDecrypt = :countDecrypt,' .
|
||||
'account_dateAdd = :dateAdd,' .
|
||||
'account_dateEdit = :dateEdit';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($account['intAccountId'], 'id');
|
||||
$Data->addParam($account['intUGroupFId'], 'userGroupId');
|
||||
$Data->addParam($account['intUserFId'], 'userId');
|
||||
$Data->addParam($account['intUEditFId'], 'userEditId');
|
||||
$Data->addParam($customerId, 'customerId');
|
||||
$Data->addParam($account['vacName'], 'name');
|
||||
$Data->addParam($account['intCategoryFid'], 'categoryId');
|
||||
$Data->addParam($account['vacLogin'], 'login');
|
||||
$Data->addParam($account['vacUrl'], 'url');
|
||||
$Data->addParam($account['vacPassword'], 'pass');
|
||||
$Data->addParam($account['vacInitialValue'], 'iv');
|
||||
$Data->addParam($account['txtNotice'], 'notes');
|
||||
$Data->addParam($account['intCountView'], 'countView');
|
||||
$Data->addParam($account['intCountDecrypt'], 'countDecrypt');
|
||||
$Data->addParam($account['datAdded'], 'dateAdd');
|
||||
$Data->addParam($account['datChanged'], 'dateEdit');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
self::$currentQuery = DBUtil::escape($query);
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al migrar cuenta'),
|
||||
DB::$txtError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrar las grupos secundarios de las cuentas desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return array resultado
|
||||
*/
|
||||
private static function migrateAccountsGroups()
|
||||
{
|
||||
$query = 'SELECT intAccId,intUGroupId FROM acc_usergroups';
|
||||
|
||||
$totalRecords = 0;
|
||||
$num = 0;
|
||||
|
||||
try {
|
||||
foreach(self::$DB->query($query) as $row){
|
||||
if (self::insertAccountsGroups($row)) {
|
||||
$num++;
|
||||
}
|
||||
$totalRecords++;
|
||||
}
|
||||
} catch(\PDOException $e){
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al obtener los grupos de cuentas'),
|
||||
$e->getMessage());
|
||||
}
|
||||
|
||||
$Log = new Log(_('Importar Grupos de Cuentas'));
|
||||
$Log->addDescription('OK');
|
||||
$Log->addDetails(_('Registros'), $num . '/' . $totalRecords);
|
||||
$Log->writeLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insertar los grupos secundarios de una cuenta en sysPass.
|
||||
*
|
||||
* @param array $accountGroup con los datos de los grupos secundarios
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return bool
|
||||
*/
|
||||
private static function insertAccountsGroups($accountGroup)
|
||||
{
|
||||
$query = 'INSERT INTO accGroups SET ' .
|
||||
'accgroup_accountId = :accountId,' .
|
||||
'accgroup_groupId = :groudId';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($accountGroup['intAccId'], 'accountId');
|
||||
$Data->addParam($accountGroup['intUGroupId'], 'groupId');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al crear grupos de cuentas'),
|
||||
DB::$txtError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrar el historail de las cuentas desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return array resultado
|
||||
*/
|
||||
private static function migrateAccountsHistory()
|
||||
{
|
||||
$query = 'SELECT intAccountId,'
|
||||
. 'intUGroupFId,'
|
||||
. 'intUserFId,'
|
||||
. 'intUEditFId,'
|
||||
. 'vacCliente,'
|
||||
. 'vacName,'
|
||||
. 'intCategoryFid,'
|
||||
. 'vacLogin,'
|
||||
. 'vacUrl,'
|
||||
. 'vacPassword,'
|
||||
. 'vacInitialValue,'
|
||||
. 'txtNotice,'
|
||||
. 'intCountView,'
|
||||
. 'intCountDecrypt,'
|
||||
. 'datAdded,'
|
||||
. 'datChanged,'
|
||||
. 'blnModificada,'
|
||||
. 'blnEliminada '
|
||||
. 'FROM acc_history';
|
||||
|
||||
$totalRecords = 0;
|
||||
$num = 0;
|
||||
|
||||
try {
|
||||
foreach(self::$DB->query($query) as $row){
|
||||
if (self::insertAccountsHistory($row)) {
|
||||
$num++;
|
||||
}
|
||||
$totalRecords++;
|
||||
}
|
||||
} catch(\PDOException $e){
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al obtener el historico de cuentas'),
|
||||
self::$DB->error);
|
||||
}
|
||||
|
||||
$Log = new Log(_('Importar Histórico de Cuentas'));
|
||||
$Log->addDescription('OK');
|
||||
$Log->addDetails(_('Registros'), $num . '/' . $totalRecords);
|
||||
$Log->writeLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insertar el historial de una cuenta en sysPass.
|
||||
*
|
||||
* @param array $accountHistory con los datos del historial de la cuenta
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return bool
|
||||
*/
|
||||
private static function insertAccountsHistory($accountHistory)
|
||||
{
|
||||
if (!is_array(self::$customersByName)) {
|
||||
$customers = Customer::getCustomers(null, true);
|
||||
self::$customersByName = array_flip($customers);
|
||||
}
|
||||
|
||||
$customer = trim($accountHistory['vacCliente']);
|
||||
|
||||
if (array_key_exists($customer, self::$customersByName)) {
|
||||
$customerId = self::$customersByName[$customer];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO accHistory SET ' .
|
||||
'acchistory_accountId = :id,' .
|
||||
'acchistory_userGroupId = :userGroupId,' .
|
||||
'acchistory_userId = :userId,' .
|
||||
'acchistory_userEditId = :userEditId,' .
|
||||
'acchistory_customerId = :customerId,' .
|
||||
'acchistory_name = :name,' .
|
||||
'acchistory_categoryId = :categoryId,' .
|
||||
'acchistory_login = :login,' .
|
||||
'acchistory_url = :url,' .
|
||||
'acchistory_pass = :pass,' .
|
||||
'acchistory_IV = :iv,' .
|
||||
'acchistory_notes = :notes,' .
|
||||
'acchistory_countView = :countView,' .
|
||||
'acchistory_countDecrypt = :countDecrypt,' .
|
||||
'acchistory_dateAdd = :dateAdd,' .
|
||||
'acchistory_dateEdit = :dateEdit,' .
|
||||
'acchistory_isModify = :isModify,' .
|
||||
'acchistory_isDeleted = :isDeleted';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($accountHistory['intAccountId'], 'id');
|
||||
$Data->addParam($accountHistory['intUGroupFId'], 'userGroupId');
|
||||
$Data->addParam($accountHistory['intUserFId'], 'userId');
|
||||
$Data->addParam($accountHistory['intUEditFId'], 'userEditId');
|
||||
$Data->addParam($customerId, 'customerId');
|
||||
$Data->addParam($accountHistory['vacName'], 'name');
|
||||
$Data->addParam($accountHistory['intCategoryFid'], 'categoryId');
|
||||
$Data->addParam($accountHistory['vacLogin'], 'login');
|
||||
$Data->addParam($accountHistory['vacUrl'], 'url');
|
||||
$Data->addParam($accountHistory['vacPassword'], 'pass');
|
||||
$Data->addParam($accountHistory['vacInitialValue'], 'iv');
|
||||
$Data->addParam($accountHistory['txtNotice'], 'notes');
|
||||
$Data->addParam($accountHistory['intCountView'], 'countView');
|
||||
$Data->addParam($accountHistory['intCountDecrypt'], 'countDecrypt');
|
||||
$Data->addParam($accountHistory['datAdded'], 'dateAdd');
|
||||
$Data->addParam($accountHistory['datChanged'], 'dateEdit');
|
||||
$Data->addParam($accountHistory['blnModificada'], 'isModify');
|
||||
$Data->addParam($accountHistory['blnEliminada'], 'isDeleted');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al crear historico de cuentas'),
|
||||
DB::$txtError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrar los archivos de de las cuentas desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return array resultado
|
||||
*/
|
||||
private static function migrateAcountsFiles()
|
||||
{
|
||||
$query = 'SELECT intAccountId,'
|
||||
. 'vacName,'
|
||||
. 'vacType,'
|
||||
. 'intSize,'
|
||||
. 'blobContent,'
|
||||
. 'vacExtension '
|
||||
. 'FROM files';
|
||||
|
||||
$totalRecords = 0;
|
||||
$num = 0;
|
||||
|
||||
try {
|
||||
foreach(self::$DB->query($query) as $row){
|
||||
if (self::insertAccountsFiles($row)) {
|
||||
$num++;
|
||||
}
|
||||
$totalRecords++;
|
||||
}
|
||||
} catch(\PDOException $e){
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al obtener los archivos de cuentas'),
|
||||
self::$DB->error);
|
||||
}
|
||||
|
||||
$Log = new Log(_('Importar Archivos de Cuentas'));
|
||||
$Log->addDescription('OK');
|
||||
$Log->addDetails(_('Registros'), $num . '/' . $totalRecords);
|
||||
$Log->writeLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insertar los archivos de una cuenta en sysPass.
|
||||
*
|
||||
* @param array $accountFile con los datos del archivo
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return bool
|
||||
*/
|
||||
private static function insertAccountsFiles($accountFile)
|
||||
{
|
||||
$query = 'INSERT INTO accFiles '
|
||||
. 'SET accfile_accountId = :id,'
|
||||
. 'accfile_name = :name,'
|
||||
. 'accfile_type = :type,'
|
||||
. 'accfile_size = :size,'
|
||||
. 'accfile_content = :blobcontent,'
|
||||
. 'accfile_extension = :extension';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($accountFile['intAccountId'], 'id');
|
||||
$Data->addParam($accountFile['vacName'], 'name');
|
||||
$Data->addParam($accountFile['vacType'], 'type');
|
||||
$Data->addParam($accountFile['intSize'], 'size');
|
||||
$Data->addParam($accountFile['blobContent'], 'blobcontent');
|
||||
$Data->addParam($accountFile['vacExtension'], 'extension');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al crear archivos de cuentas'),
|
||||
DB::$txtError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrar las categorías de las cuentas desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return array resultado
|
||||
*/
|
||||
private static function migrateAccountsCategories()
|
||||
{
|
||||
$query = 'SELECT intCategoryId,vacCategoryName FROM categories';
|
||||
|
||||
$totalRecords = 0;
|
||||
$num = 0;
|
||||
|
||||
try {
|
||||
foreach(self::$DB->query($query) as $row){
|
||||
if (self::insertAccountsCategories($row)) {
|
||||
$num++;
|
||||
}
|
||||
$totalRecords++;
|
||||
}
|
||||
} catch(\PDOException $e){
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al obtener las categorías de cuentas'),
|
||||
self::$DB->error);
|
||||
}
|
||||
|
||||
$Log = new Log(_('Importar Categorías de Cuentas'));
|
||||
$Log->addDescription('OK');
|
||||
$Log->addDetails(_('Registros'), $num . '/' . $totalRecords);
|
||||
$Log->writeLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insertar las categorías en sysPass.
|
||||
*
|
||||
* @param array $accountCategory con los datos de la categoría
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return bool
|
||||
*/
|
||||
private static function insertAccountsCategories($accountCategory)
|
||||
{
|
||||
$query = 'INSERT INTO categories SET category_id = :id,category_name = :name';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($accountCategory['intCategoryId'], 'id');
|
||||
$Data->addParam($accountCategory['vacCategoryName'], 'name');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al crear categorías de cuentas'),
|
||||
DB::$txtError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrar los usuarios desde desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return array resultado
|
||||
*/
|
||||
private static function migrateUsers()
|
||||
{
|
||||
$query = 'SELECT intUserId,'
|
||||
. 'vacUName,'
|
||||
. 'intUGroupFid,'
|
||||
. 'vacULogin,'
|
||||
. 'vacUPassword,'
|
||||
. 'vacUEmail,'
|
||||
. 'txtUNotes,'
|
||||
. 'intUCount,'
|
||||
. 'intUProfile,'
|
||||
. 'datULastLogin,'
|
||||
. 'blnIsAdminApp,'
|
||||
. 'blnIsAdminAcc,'
|
||||
. 'vacUserMPwd,'
|
||||
. 'vacUserMIv,'
|
||||
. 'datULastUpdate,'
|
||||
. 'datUserLastUpdateMPass,'
|
||||
. 'blnFromLdap,'
|
||||
. 'blnDisabled '
|
||||
. 'FROM users '
|
||||
. 'WHERE intUserId <> ' . Session::getUserId();
|
||||
|
||||
$totalRecords = 0;
|
||||
$num = 0;
|
||||
|
||||
try {
|
||||
foreach(self::$DB->query($query) as $row){
|
||||
if (self::insertUsers($row)) {
|
||||
$num++;
|
||||
}
|
||||
$totalRecords++;
|
||||
}
|
||||
} catch(\PDOException $e){
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al obtener los usuarios'),
|
||||
self::$DB->error);
|
||||
}
|
||||
|
||||
$Log = new Log(_('Importar Usuarios'));
|
||||
$Log->addDescription('OK');
|
||||
$Log->addDetails(_('Registros'), $num . '/' . $totalRecords);
|
||||
$Log->writeLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insertar los usuarios en sysPass.
|
||||
*
|
||||
* @param array $users con los datos del usuario
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return bool
|
||||
*
|
||||
* El usuario importado está deshabilitado
|
||||
*/
|
||||
private static function insertUsers($users)
|
||||
{
|
||||
$query = 'INSERT INTO usrData '
|
||||
. 'SET user_id = :id,'
|
||||
. 'user_name = :name,'
|
||||
. 'user_groupId = :goupId,'
|
||||
. 'user_login = :login,'
|
||||
. 'user_pass = :pass,'
|
||||
. 'user_mPass = :mpass,'
|
||||
. 'user_mIV = :miv,'
|
||||
. 'user_email = :email,'
|
||||
. 'user_notes = :notes,'
|
||||
. 'user_count = :count,'
|
||||
. 'user_profileId = 0,'
|
||||
. 'user_lastLogin = :lastLogin,'
|
||||
. 'user_lastUpdate = :lastUpdate,'
|
||||
. 'user_lastUpdateMPass = :lastUpdateMPass,'
|
||||
. 'user_isAdminApp = :isAdminApp,'
|
||||
. 'user_isAdminAcc = :isAdminAcc,'
|
||||
. 'user_isLdap = :isLdap,'
|
||||
. 'user_isDisabled = 1,'
|
||||
. 'user_isMigrate = 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($users['intUserId'], 'id');
|
||||
$Data->addParam($users['vacUName'], 'name');
|
||||
$Data->addParam($users['intUGroupFid'], 'groupId');
|
||||
$Data->addParam($users['vacULogin'], 'login');
|
||||
$Data->addParam($users['vacUPassword'], 'pass');
|
||||
$Data->addParam($users['vacUserMPwd'], 'mpass');
|
||||
$Data->addParam($users['vacUserMIv'], 'miv');
|
||||
$Data->addParam($users['vacUEmail'], 'email');
|
||||
$Data->addParam($users['txtUNotes'], 'notes');
|
||||
$Data->addParam($users['intUCount'], 'count');
|
||||
$Data->addParam($users['datULastLogin'], 'lastLogin');
|
||||
$Data->addParam($users['datULastUpdate'], 'lastUpdate');
|
||||
$Data->addParam($users['datUserLastUpdateMPass'], 'lastUpdateMPass');
|
||||
$Data->addParam($users['blnIsAdminApp'], 'isAdminApp');
|
||||
$Data->addParam($users['blnIsAdminAcc'], 'isAdminAcc');
|
||||
$Data->addParam($users['blnFromLdap'], 'isLdap');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al crear usuarios'),
|
||||
DB::$txtError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrar los grupos de usuarios desde desde phpPMS.
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return array resultado
|
||||
*/
|
||||
private static function migrateUsersGroups()
|
||||
{
|
||||
$query = 'SELECT intUGroupId,vacUGroupName,vacUGroupDesc FROM usergroups';
|
||||
|
||||
$totalRecords = 0;
|
||||
$num = 0;
|
||||
|
||||
try {
|
||||
foreach(self::$DB->query($query) as $row){
|
||||
if (self::insertUsersGroups($row)) {
|
||||
$num++;
|
||||
}
|
||||
$totalRecords++;
|
||||
}
|
||||
} catch(\PDOException $e){
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al obtener los grupos de usuarios'),
|
||||
self::$DB->error);
|
||||
}
|
||||
|
||||
$Log = new Log(_('Importar Grupos de Usuarios'));
|
||||
$Log->addDescription('OK');
|
||||
$Log->addDetails(_('Registros'), $num . '/' . $totalRecords);
|
||||
$Log->writeLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insertar los grupos de usuarios en sysPass.
|
||||
*
|
||||
* @param array $usersGroups con los datos del grupo
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
* @return bool
|
||||
*/
|
||||
private static function insertUsersGroups($usersGroups)
|
||||
{
|
||||
$query = 'INSERT INTO usrGroups '
|
||||
. 'SET usergroup_id = :id,'
|
||||
. 'usergroup_name = :name,'
|
||||
. 'usergroup_description = :description';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($usersGroups['intUGroupId'], 'id');
|
||||
$Data->addParam($usersGroups['vacUGroupName'], 'name');
|
||||
$Data->addParam($usersGroups['vacUGroupDesc'], 'description');
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_CRITICAL,
|
||||
_('Error al crear los grupos de usuarios'),
|
||||
DB::$txtError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrar la configuración desde phpPMS.
|
||||
*
|
||||
* @return array resultado
|
||||
*/
|
||||
private static function migrateConfig()
|
||||
{
|
||||
// Obtener la configuración actual
|
||||
self::getSourceConfig();
|
||||
|
||||
$skip = array('version',
|
||||
'installed',
|
||||
'install',
|
||||
'dbhost',
|
||||
'dbname',
|
||||
'dbuser',
|
||||
'dbpass',
|
||||
'siteroot',
|
||||
'sitelang',
|
||||
'sitename',
|
||||
'siteshortname',
|
||||
'md5_pass',
|
||||
'password_show',
|
||||
'lastupdatempass',
|
||||
'passwordsalt');
|
||||
|
||||
$totalParams = count(self::$oldConfig);
|
||||
$num = 0;
|
||||
|
||||
// Guardar la nueva configuración
|
||||
foreach (self::$oldConfig as $key => $value) {
|
||||
if (array_key_exists($key, $skip)) {
|
||||
continue;
|
||||
}
|
||||
// FIXME
|
||||
// Config::setValue($key, $value);
|
||||
$num++;
|
||||
}
|
||||
|
||||
$Log = new Log(_('Importar Configuración'));
|
||||
$Log->addDescription('OK');
|
||||
$Log->addDetails(_('Registros'), $num . '/' . $totalParams);
|
||||
$Log->writeLog();
|
||||
}
|
||||
}
|
||||
@@ -74,14 +74,7 @@ class Log extends ActionLog
|
||||
// Obtenemos el número total de registros
|
||||
DB::setFullRowCount();
|
||||
|
||||
// Devolver un array siempre
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return false;
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
self::$numRows = $Data->getQueryNumRows();
|
||||
|
||||
|
||||
@@ -227,8 +227,6 @@ class Category extends CategoryBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
}
|
||||
@@ -69,15 +69,10 @@ class CategorySearch extends CategoryBase implements ItemSearchInterface
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
/** @var array $queryRes */
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
|
||||
@@ -219,9 +219,7 @@ class CustomField extends CustomFieldBase implements ItemInterface
|
||||
$Data->addParam($this->itemData->getModule());
|
||||
$Data->addParam($id);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$customFields = [];
|
||||
|
||||
@@ -293,12 +291,10 @@ class CustomField extends CustomFieldBase implements ItemInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getModule());
|
||||
|
||||
DB::setReturnArray();
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array('hash' => '');
|
||||
if (count($queryRes) === 0) {
|
||||
return ['hash' => ''];
|
||||
}
|
||||
|
||||
foreach ($queryRes as $CustomFieldDef) {
|
||||
|
||||
@@ -225,11 +225,9 @@ class CustomFieldDef extends CustomFieldBase implements ItemInterface
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
if (count($queryRes) === 0) {
|
||||
throw new SPException(SPException::SP_INFO, _('No se encontraron campos personalizados'));
|
||||
}
|
||||
|
||||
|
||||
@@ -73,16 +73,11 @@ class CustomFieldDefSearch extends CustomFieldBase implements ItemSearchInterfac
|
||||
$Data->addParam($SearchData->getLimitStart());
|
||||
$Data->addParam($SearchData->getLimitCount());
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$customFields = array();
|
||||
$customFields = [];
|
||||
|
||||
foreach ($queryRes as $CustomField) {
|
||||
/**
|
||||
|
||||
@@ -73,11 +73,9 @@ class CustomFieldsUtil
|
||||
$Data->setMapClassName('SP\DataModel\CustomFieldData');
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
if (count($queryRes) === 0) {
|
||||
$Log->addDescription(_('Fin'));
|
||||
$Log->writeLog();
|
||||
|
||||
|
||||
@@ -252,8 +252,6 @@ class Customer extends CustomerBase implements ItemInterface, ItemSelectInterfac
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,14 +71,9 @@ class CustomerSearch extends CustomerBase implements ItemSearchInterface
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
|
||||
@@ -80,14 +80,9 @@ class FileSearch extends FileBase implements ItemSearchInterface
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
|
||||
@@ -63,15 +63,7 @@ class FileUtil
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($accountId);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -270,8 +270,6 @@ class Group extends GroupBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,11 +118,7 @@ class GroupAccounts extends GroupAccountsBase implements ItemInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$this->itemData = DB::getResults($Data);
|
||||
|
||||
return $this;
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,8 +177,6 @@ class GroupAccounts extends GroupAccountsBase implements ItemInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
}
|
||||
@@ -59,9 +59,7 @@ class GroupAccountsUtil
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($accountId);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,14 +71,9 @@ class GroupSearch extends GroupBase implements ItemSearchInterface
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
|
||||
@@ -122,9 +122,7 @@ class GroupUsers extends GroupUsersBase implements ItemInterface, ItemSelectInte
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -274,9 +274,7 @@ class Profile extends ProfileBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,14 +73,9 @@ class ProfileSearch extends ProfileBase implements ItemSearchInterface
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
|
||||
@@ -75,11 +75,9 @@ class ProfileUtil
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
if (count($queryRes) === 0) {
|
||||
$Log->setLogLevel(Log::ERROR);
|
||||
$Log->addDescription(_('Error al obtener perfiles'));
|
||||
return false;
|
||||
@@ -168,8 +166,6 @@ class ProfileUtil
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(serialize($this->itemData));
|
||||
$Data->addParam($this->itemData->getLinkHash());
|
||||
$Data->addParam($this->itemData->getItemId());
|
||||
$Data->addParam($this->itemData->getPublicLinkId());
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al actualizar enlace'));
|
||||
@@ -130,8 +130,8 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($this->itemData->getLinkHash());
|
||||
$Data->addParam($this->itemData->getItemId());
|
||||
$Data->addParam($this->itemData->getPublicLinkHash());
|
||||
$Data->addParam($this->itemData->getPublicLinkItemId());
|
||||
$Data->addParam(serialize($this->itemData));
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
@@ -187,7 +187,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
|
||||
$Log = new Log(_('Eliminar Enlace'));
|
||||
$Log->addDescription(_('Enlace eliminado'));
|
||||
$Log->addDetails(Html::strongText(_('ID')), $this->itemData->getItemId());
|
||||
$Log->addDetails(Html::strongText(_('ID')), $this->itemData->getPublicLinkId());
|
||||
$Log->writeLog();
|
||||
|
||||
Email::sendEmail($Log);
|
||||
@@ -216,8 +216,8 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam(serialize($this->itemData));
|
||||
$Data->addParam($this->itemData->getLinkHash());
|
||||
$Data->addParam($this->itemData->getItemId());
|
||||
$Data->addParam($this->itemData->getPublicLinkHash());
|
||||
$Data->addParam($this->itemData->getPublicLinkId());
|
||||
|
||||
if (DB::getQuery($Data) === false) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al renovar enlace'));
|
||||
@@ -237,7 +237,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return PublicLinkListData
|
||||
* @return PublicLinkData
|
||||
* @throws SPException
|
||||
*/
|
||||
public function getById($id)
|
||||
@@ -249,7 +249,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
FROM publicLinks WHERE publicLink_id = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName('SP\DataModel\PublicLinkBaseData');
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($id);
|
||||
|
||||
@@ -269,17 +269,9 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
$PublicLink = Util::castToClass($this->getDataModel(), $PublicLink);
|
||||
}
|
||||
|
||||
$PublicLinkListData = new PublicLinkListData();
|
||||
$PublicLinkListData->setPublicLinkItemId($queryRes->getPublicLinkItemId());
|
||||
$PublicLinkListData->setAccountName(AccountUtil::getAccountNameById($PublicLink->getItemId()));
|
||||
$PublicLinkListData->setUserLogin(UserUtil::getUserLoginById($PublicLink->getUserId()));
|
||||
$PublicLinkListData->setNotify($PublicLink->isNotify() ? _('ON') : _('OFF'));
|
||||
$PublicLinkListData->setDateAdd(date('Y-m-d H:i', $PublicLink->getDateAdd()));
|
||||
$PublicLinkListData->setDateExpire(date('Y-m-d H:i', $PublicLink->getDateExpire()));
|
||||
$PublicLinkListData->setCountViews($PublicLink->getCountViews() . '/' . $PublicLink->getMaxCountViews());
|
||||
$PublicLinkListData->setUseInfo($PublicLink->getUseInfo());
|
||||
$PublicLink->setPublicLinkId($id);
|
||||
|
||||
return $PublicLinkListData;
|
||||
return $PublicLink;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,20 +283,12 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
'SELECT publicLink_id, publicLink_hash, publicLink_linkData FROM publicLinks';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName('SP\DataModel\PublicLinkListData');
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$publicLinks = [];
|
||||
|
||||
foreach ($queryRes as $PublicLinkListData) {
|
||||
foreach (DB::getResultsArray($Data) as $PublicLinkListData) {
|
||||
/**
|
||||
* @var PublicLinkData $PublicLinkData
|
||||
* @var PublicLinkListData $PublicLinkListData
|
||||
@@ -316,20 +300,36 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
$PublicLinkData = Util::castToClass($this->getDataModel(), $PublicLinkData);
|
||||
}
|
||||
|
||||
$PublicLinkListData->setAccountName(AccountUtil::getAccountNameById($PublicLinkData->getItemId()));
|
||||
$PublicLinkListData->setUserLogin(UserUtil::getUserLoginById($PublicLinkData->getUserId()));
|
||||
$PublicLinkListData->setNotify($PublicLinkData->isNotify() ? _('ON') : _('OFF'));
|
||||
$PublicLinkListData->setDateAdd(date('Y-m-d H:i', $PublicLinkData->getDateAdd()));
|
||||
$PublicLinkListData->setDateExpire(date('Y-m-d H:i', $PublicLinkData->getDateExpire()));
|
||||
$PublicLinkListData->setCountViews($PublicLinkData->getCountViews() . '/' . $PublicLinkData->getMaxCountViews());
|
||||
$PublicLinkListData->setUseInfo($PublicLinkData->getUseInfo());
|
||||
$PublicLinkData->setPublicLinkId($PublicLinkListData->getPublicLinkId());
|
||||
|
||||
$publicLinks[] = $PublicLinkListData;
|
||||
$publicLinks[] = $this->getItemForList($PublicLinkData);
|
||||
}
|
||||
|
||||
return $publicLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve los datos de un enlace para mostrarlo
|
||||
*
|
||||
* @param PublicLinkData $PublicLinkData
|
||||
* @return PublicLinkListData
|
||||
*/
|
||||
public function getItemForList(PublicLinkData $PublicLinkData)
|
||||
{
|
||||
$PublicLinkListData = new PublicLinkListData();
|
||||
$PublicLinkListData->setPublicLinkId($PublicLinkData->getPublicLinkId());
|
||||
$PublicLinkListData->setPublicLinkHash($PublicLinkData->getLinkHash());
|
||||
$PublicLinkListData->setAccountName(AccountUtil::getAccountNameById($PublicLinkData->getItemId()));
|
||||
$PublicLinkListData->setUserLogin(UserUtil::getUserLoginById($PublicLinkData->getUserId()));
|
||||
$PublicLinkListData->setNotify($PublicLinkData->isNotify() ? _('ON') : _('OFF'));
|
||||
$PublicLinkListData->setDateAdd(date('Y-m-d H:i', $PublicLinkData->getDateAdd()));
|
||||
$PublicLinkListData->setDateExpire(date('Y-m-d H:i', $PublicLinkData->getDateExpire()));
|
||||
$PublicLinkListData->setCountViews($PublicLinkData->getCountViews() . '/' . $PublicLinkData->getMaxCountViews());
|
||||
$PublicLinkListData->setUseInfo($PublicLinkData->getUseInfo());
|
||||
|
||||
return $PublicLinkListData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id int
|
||||
* @return mixed
|
||||
@@ -361,7 +361,7 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
FROM publicLinks WHERE publicLink_hash = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName('SP\DataModel\PublicLinkBaseData');
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($hash);
|
||||
|
||||
@@ -381,8 +381,37 @@ class PublicLink extends PublicLinkBase implements ItemInterface
|
||||
$PublicLink = Util::castToClass($this->getDataModel(), $PublicLink);
|
||||
}
|
||||
|
||||
$PublicLink->setItemId($queryRes->getPublicLinkItemId());
|
||||
$PublicLink->setPublicLinkId($queryRes->getPublicLinkId());
|
||||
|
||||
return $PublicLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el hash asociado a un elemento
|
||||
*
|
||||
* @param int $itemId
|
||||
* @return PublicLinkData
|
||||
* @throws SPException
|
||||
*/
|
||||
public function getHashForItem($itemId)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT publicLink_hash FROM publicLinks WHERE publicLink_itemId = ? LIMIT 1';
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
$Data->addParam($itemId);
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
error_log(print_r($queryRes, true));
|
||||
error_log(print_r($itemId, true));
|
||||
|
||||
if ($queryRes === false) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al obtener enlace'));
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
}
|
||||
@@ -52,9 +52,9 @@ abstract class PublicLinkBase extends ItemBase
|
||||
public function __construct($itemData = null)
|
||||
{
|
||||
if (!$this->dataModel) {
|
||||
$this->setDataModel('SP\DataModel\PublicLinkData');
|
||||
$this->setDataModel('SP\DataModel\PublicLinkBaseData');
|
||||
}
|
||||
|
||||
|
||||
parent::__construct($itemData);
|
||||
}
|
||||
|
||||
@@ -88,10 +88,13 @@ abstract class PublicLinkBase extends ItemBase
|
||||
*/
|
||||
protected final function createLinkHash($refresh = false)
|
||||
{
|
||||
if ($this->itemData->getLinkHash() === ''
|
||||
|| $refresh === true
|
||||
if ($refresh === true
|
||||
|| $this->itemData->getLinkHash() === ''
|
||||
) {
|
||||
$this->itemData->setLinkHash(hash('sha256', uniqid()));
|
||||
$hash = hash('sha256', uniqid('sysPassPublicLink', true));
|
||||
|
||||
$this->itemData->setPublicLinkHash($hash);
|
||||
$this->itemData->setLinkHash($hash);
|
||||
}
|
||||
|
||||
return $this->itemData->getLinkHash();
|
||||
|
||||
@@ -59,14 +59,9 @@ class PublicLinkSearch extends PublicLinkBase implements ItemSearchInterface
|
||||
$Data->addParam($SearchData->getLimitStart());
|
||||
$Data->addParam($SearchData->getLimitCount());
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$publicLinks = [];
|
||||
$publicLinks['count'] = $Data->getQueryNumRows();
|
||||
@@ -85,8 +80,8 @@ class PublicLinkSearch extends PublicLinkBase implements ItemSearchInterface
|
||||
$PublicLinkListData->setAccountName(AccountUtil::getAccountNameById($PublicLinkData->getItemId()));
|
||||
$PublicLinkListData->setUserLogin(UserUtil::getUserLoginById($PublicLinkData->getUserId()));
|
||||
$PublicLinkListData->setNotify(($PublicLinkData->isNotify()) ? _('ON') : _('OFF'));
|
||||
$PublicLinkListData->setDateAdd(date("Y-m-d H:i", $PublicLinkData->getDateAdd()));
|
||||
$PublicLinkListData->setDateExpire(date("Y-m-d H:i", $PublicLinkData->getDateExpire()));
|
||||
$PublicLinkListData->setDateAdd(date('Y-m-d H:i', $PublicLinkData->getDateAdd()));
|
||||
$PublicLinkListData->setDateExpire(date('Y-m-d H:i', $PublicLinkData->getDateExpire()));
|
||||
$PublicLinkListData->setCountViews($PublicLinkData->getCountViews() . '/' . $PublicLinkData->getMaxCountViews());
|
||||
$PublicLinkListData->setUseInfo($PublicLinkData->getUseInfo());
|
||||
|
||||
|
||||
@@ -181,9 +181,7 @@ class Tag extends TagBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->setQuery($query);
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,14 +63,9 @@ class TagSearch extends TagBase implements ItemSearchInterface
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
|
||||
@@ -297,11 +297,10 @@ class User extends UserBase implements ItemInterface, ItemSelectInterface
|
||||
$Data->setMapClassName($this->getDataModel());
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
try {
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
} catch (SPException $e) {
|
||||
throw new SPException(SPException::SP_ERROR, _('Error al obtener los usuarios'));
|
||||
}
|
||||
|
||||
|
||||
@@ -84,14 +84,9 @@ class UserSearch extends UserBase implements ItemSearchInterface
|
||||
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
DB::setFullRowCount();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
$queryRes = DB::getResultsArray($Data);
|
||||
|
||||
$queryRes['count'] = $Data->getQueryNumRows();
|
||||
|
||||
|
||||
@@ -140,12 +140,9 @@ class UserUtil
|
||||
'SELECT user_id, user_login, user_name FROM usrData ORDER BY user_login';
|
||||
|
||||
$Data = new QueryData();
|
||||
// $Data->setMapClassName('\SP\DataModel\UserData');
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
return DB::getResults($Data);
|
||||
return DB::getResultsArray($Data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
namespace SP\Storage;
|
||||
|
||||
use PDO;
|
||||
use SP\Config\Config;
|
||||
use PDOStatement;
|
||||
use SP\Core\DiFactory;
|
||||
use SP\Log\Log;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
@@ -39,26 +39,10 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'
|
||||
*/
|
||||
class DB
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public static $txtError = '';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $numError = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $lastId;
|
||||
/**
|
||||
* @var bool Resultado como array
|
||||
*/
|
||||
private static $retArray = false;
|
||||
/**
|
||||
* @var bool Resultado como un objeto PDO
|
||||
*/
|
||||
private static $returnRawData = false;
|
||||
/**
|
||||
* @var bool Contar el número de filas totales
|
||||
*/
|
||||
@@ -85,18 +69,27 @@ class DB
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer si se devuelve un array de objetos siempre
|
||||
* Devolver los resultados en array
|
||||
*
|
||||
* @param QueryData $queryData
|
||||
* @return array
|
||||
*/
|
||||
public static function setReturnArray()
|
||||
public static function getResultsArray(QueryData $queryData)
|
||||
{
|
||||
self::$retArray = true;
|
||||
$results = self::getResults($queryData);
|
||||
|
||||
if ($results === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return is_object($results) ? [$results] : $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los resultados de una consulta.
|
||||
*
|
||||
* @param $queryData QueryData Los datos de la consulta
|
||||
* @return bool|array devuelve bool si hay un error. Devuelve array con el array de registros devueltos
|
||||
* @return mixed devuelve bool si hay un error. Devuelve array con el array de registros devueltos
|
||||
*/
|
||||
public static function getResults(QueryData $queryData)
|
||||
{
|
||||
@@ -107,33 +100,22 @@ class DB
|
||||
|
||||
try {
|
||||
$db = new DB();
|
||||
$doQuery = $db->doQuery($queryData, self::$returnRawData);
|
||||
$numRows = (self::$fullRowCount === false) ? $db->numRows : $db->getFullRowCount($queryData);
|
||||
$queryData->setQueryNumRows($numRows);
|
||||
$db->doQuery($queryData);
|
||||
|
||||
if (self::$fullRowCount === true) {
|
||||
$db->getFullRowCount($queryData);
|
||||
}
|
||||
} catch (SPException $e) {
|
||||
self::logDBException($queryData->getQuery(), $e->getMessage(), $e->getCode(), __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::$returnRawData
|
||||
&& is_object($doQuery)
|
||||
&& get_class($doQuery) === 'PDOStatement'
|
||||
) {
|
||||
return $doQuery;
|
||||
} elseif ($db->numRows === 0) {
|
||||
if (self::$retArray) {
|
||||
self::resetVars();
|
||||
return [];
|
||||
} else {
|
||||
self::resetVars();
|
||||
return false;
|
||||
}
|
||||
} elseif ($db->numRows === 1 && self::$retArray === false) {
|
||||
self::resetVars();
|
||||
self::resetVars();
|
||||
|
||||
if ($db->numRows === 1) {
|
||||
return $db->lastResult[0];
|
||||
}
|
||||
|
||||
self::resetVars();
|
||||
return $db->lastResult;
|
||||
}
|
||||
|
||||
@@ -142,9 +124,7 @@ class DB
|
||||
*/
|
||||
private static function resetVars()
|
||||
{
|
||||
self::$returnRawData = false;
|
||||
self::$fullRowCount = false;
|
||||
self::$retArray = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,15 +132,15 @@ class DB
|
||||
*
|
||||
* @param $queryData QueryData Los datos de la consulta
|
||||
* @param $getRawData bool realizar la consulta para obtener registro a registro
|
||||
* @return false|int devuelve bool si hay un error. Devuelve int con el número de registros
|
||||
* @return bool
|
||||
* @throws SPException
|
||||
*/
|
||||
public function doQuery(QueryData $queryData, $getRawData = false)
|
||||
{
|
||||
$isSelect = preg_match("/^(select|show)\s/i", $queryData->getQuery());
|
||||
|
||||
// Limpiar valores de caché y errores
|
||||
$this->lastResult = array();
|
||||
// Limpiar valores de caché
|
||||
$this->lastResult = [];
|
||||
|
||||
try {
|
||||
$queryRes = $this->prepareQueryData($queryData);
|
||||
@@ -169,17 +149,18 @@ class DB
|
||||
}
|
||||
|
||||
if ($isSelect) {
|
||||
if (!$getRawData) {
|
||||
$this->numFields = $queryRes->columnCount();
|
||||
$this->lastResult = $queryRes->fetchAll();
|
||||
} else {
|
||||
if ($getRawData) {
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
// $queryRes->closeCursor();
|
||||
|
||||
$this->numFields = $queryRes->columnCount();
|
||||
$this->lastResult = $queryRes->fetchAll();
|
||||
$this->numRows = count($this->lastResult);
|
||||
|
||||
$queryData->setQueryNumRows($this->numRows);
|
||||
}
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,11 +264,11 @@ class DB
|
||||
$queryRes = $this->prepareQueryData($queryData, true);
|
||||
$num = (int)$queryRes->fetchColumn();
|
||||
$queryRes->closeCursor();
|
||||
|
||||
return $num;
|
||||
$queryData->setQueryNumRows($num);
|
||||
} catch (SPException $e) {
|
||||
error_log('Exception: ' . $e->getMessage());
|
||||
throw new SPException(SPException::SP_CRITICAL, $e->getMessage(), $e->getCode());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,14 +294,33 @@ class DB
|
||||
error_log($Log->getDetails());
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver los resultados como objeto PDOStatement
|
||||
*
|
||||
* @param QueryData $queryData
|
||||
* @return PDOStatement|false
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public static function getResultsRaw(QueryData $queryData)
|
||||
{
|
||||
try {
|
||||
$db = new DB();
|
||||
return $db->doQuery($queryData, true);
|
||||
} catch (SPException $e) {
|
||||
self::logDBException($queryData->getQuery(), $e->getMessage(), $e->getCode(), __FUNCTION__);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Realizar una consulta y devolver el resultado sin datos
|
||||
*
|
||||
* @param QueryData $queryData Los datos para realizar la consulta
|
||||
* @param $getRawData bool Si se deben de obtener los datos como PDOStatement
|
||||
* @param QueryData $queryData Los datos para realizar la consulta
|
||||
* @return bool
|
||||
* @throws SPException
|
||||
*/
|
||||
public static function getQuery(QueryData $queryData, $getRawData = false)
|
||||
public static function getQuery(QueryData $queryData)
|
||||
{
|
||||
if ($queryData->getQuery() === '') {
|
||||
return false;
|
||||
@@ -328,12 +328,9 @@ class DB
|
||||
|
||||
try {
|
||||
$db = new DB();
|
||||
$db->doQuery($queryData, $getRawData);
|
||||
$queryData->setQueryNumRows($db->numRows);
|
||||
$db->doQuery($queryData);;
|
||||
} catch (SPException $e) {
|
||||
self::logDBException($queryData->getQuery(), $e->getMessage(), $e->getCode(), __FUNCTION__);
|
||||
self::$txtError = $e->getMessage();
|
||||
self::$numError = $e->getCode();
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -341,16 +338,6 @@ class DB
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer si se devuelven los datos obtenidos como PDOStatement
|
||||
*
|
||||
* @param bool $on
|
||||
*/
|
||||
public static function setReturnRawData($on = true)
|
||||
{
|
||||
self::$returnRawData = (bool)$on;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establecer si es necesario contar el número total de resultados devueltos
|
||||
*/
|
||||
|
||||
@@ -64,48 +64,6 @@ class DBUtil
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener los datos para generar un select.
|
||||
*
|
||||
* @param $tblName string con el nombre de la tabla a cunsultar
|
||||
* @param $tblColId string con el nombre de la columna del tipo Id a mostrar
|
||||
* @param $tblColName string con el nombre de la columna del tipo Name a mostrar
|
||||
* @param $arrFilter array con las columnas a filtrar
|
||||
* @param $arrOrder array con el orden de las columnas
|
||||
* @return array con los valores del select con el Id como clave y el nombre como valor
|
||||
*/
|
||||
// FIXME
|
||||
public static function getValuesForSelect($tblName, $tblColId, $tblColName, $arrFilter = NULL, $arrOrder = NULL)
|
||||
{
|
||||
if (!$tblName || !$tblColId || !$tblColName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$strFilter = is_array($arrFilter) ? ' WHERE ' . implode(' OR ', $arrFilter) : '';
|
||||
$strOrder = is_array($arrOrder) ? ' ORDER BY ' . implode(',', $arrOrder) : 'ORDER BY ' . $tblColName . ' ASC';
|
||||
|
||||
$query = "SELECT $tblColId, $tblColName FROM $tblName $strFilter $strOrder";
|
||||
|
||||
$Data = new QueryData();
|
||||
$Data->setQuery($query);
|
||||
|
||||
DB::setReturnArray();
|
||||
|
||||
$queryRes = DB::getResults($Data);
|
||||
|
||||
if ($queryRes === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$arrValues = array();
|
||||
|
||||
foreach ($queryRes as $row) {
|
||||
$arrValues[$row->$tblColId] = $row->$tblColName;
|
||||
}
|
||||
|
||||
return $arrValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapar una cadena de texto con funciones de mysqli.
|
||||
*
|
||||
|
||||
@@ -51,7 +51,11 @@ class ImageUtil
|
||||
return false;
|
||||
}
|
||||
|
||||
$im = imagecreatetruecolor(strlen($text) * 20, 30);
|
||||
$im = @imagecreatetruecolor(strlen($text) * 20, 30);
|
||||
|
||||
if ($im === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Colores de la imagen
|
||||
$bgColor = imagecolorallocate($im, 245, 245, 245);
|
||||
|
||||
@@ -637,10 +637,6 @@ pre, code, samp, kbd {
|
||||
width: 15em;
|
||||
}
|
||||
|
||||
#content .data-rows li.cell-actions:hover {
|
||||
background-color: #fffef0 !important
|
||||
}
|
||||
|
||||
#content .data-rows li.cell-nodata img, #content .data-rows li.cell-actions img, #content #data-search .account-info img, #content #data-search .account-actions img {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
|
||||
2
inc/themes/material-blue/css/styles.min.css
vendored
2
inc/themes/material-blue/css/styles.min.css
vendored
File diff suppressed because one or more lines are too long
@@ -46,7 +46,7 @@
|
||||
<tr>
|
||||
<td class="descField"><?php echo _('Clave'); ?></td>
|
||||
<td class="valField">
|
||||
<?php if (Checks::accountPassToImageIsEnabled()): ?>
|
||||
<?php if ($useImage): ?>
|
||||
<img class="account-pass-image" src="data:image/png;base64,<?php echo $accountPass; ?>"/>
|
||||
<?php else: ?>
|
||||
<span id="account-pass"><?php echo $accountPass; ?></span>
|
||||
@@ -54,15 +54,15 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="account-actions">
|
||||
<?php if (!Checks::accountPassToImageIsEnabled()): ?>
|
||||
<div class="action">
|
||||
<?php if (!$useImage): ?>
|
||||
<button id="btnClipPass"
|
||||
class="btn-action mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored mdl-color--indigo-A200"
|
||||
data-clipboard-target="#account-pass"
|
||||
data-action-id="<?php echo \SP\Core\ActionsInterface::ACTION_ACC_VIEW_PASS; ?>"
|
||||
data-item-id="<?php echo $accountId; ?>"
|
||||
data-sk="<?php echo $sk; ?>"
|
||||
data-history="<?php echo $accountIsHistory; ?>"
|
||||
data-history="0"
|
||||
data-onclick="account/copypass">
|
||||
<i class="material-icons">content_paste</i>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user