Ejemplo n.º 1
0
$sk = SP\Request::analyze('sk', false);
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
    SP\Response::printJSON(_('CONSULTA INVÁLIDA'));
}
$actionId = SP\Request::analyze('actionId', 0);
$onCloseAction = SP\Request::analyze('onCloseAction');
$activeTab = SP\Request::analyze('activeTab', 0);
$exportPassword = SP\Request::analyzeEncrypted('exportPwd');
$exportPasswordR = SP\Request::analyzeEncrypted('exportPwdR');
$doActionOnClose = "sysPassUtil.Common.doAction({$actionId},'',{$activeTab});";
if ($actionId === SP\Controller\ActionsInterface::ACTION_CFG_BACKUP) {
    if (SP\Util::demoIsEnabled()) {
        SP\Response::printJSON(_('Ey, esto es una DEMO!!'));
    }
    if (!SP\Backup::doBackup()) {
        SP\Log::writeNewLogAndEmail(_('Realizar Backup'), _('Error al realizar el backup'));
        SP\Response::printJSON(_('Error al realizar el backup') . ';;' . _('Revise el registro de eventos para más detalles'));
    }
    SP\Log::writeNewLogAndEmail(_('Realizar Backup'), _('Copia de la aplicación y base de datos realizada correctamente'));
    SP\Response::printJSON(_('Proceso de backup finalizado'), 0, $doActionOnClose);
} elseif ($actionId === SP\Controller\ActionsInterface::ACTION_CFG_EXPORT) {
    if (!empty($exportPassword) && $exportPassword !== $exportPasswordR) {
        SP\Response::printJSON(_('Las claves no coinciden'));
    }
    if (!\SP\XmlExport::doExport($exportPassword)) {
        SP\Log::writeNewLogAndEmail(_('Realizar Exportación'), _('Error al realizar la exportación de cuentas'));
        SP\Response::printJSON(_('Error al realizar la exportación') . ';;' . _('Revise el registro de eventos para más detalles'));
    }
    SP\Log::writeNewLogAndEmail(_('Realizar Exportación'), _('Exportación de cuentas realizada correctamente'));
    SP\Response::printJSON(_('Proceso de exportación finalizado'), 0, $doActionOnClose);
}
Ejemplo n.º 2
0
        $AccountHistory = new SP\AccountHistory();
        if (!$AccountHistory->updateAccountsMasterPass($currentMasterPass, $newMasterPass, $hashMPass)) {
            SP\Response::printJSON(_('Errores al actualizar las claves de las cuentas del histórico'));
        }
        if (!\SP\CustomFields::updateCustomFieldsCrypt($currentMasterPass, $newMasterPass)) {
            SP\Response::printJSON(_('Errores al actualizar datos de campos personalizados'));
        }
    }
    if (SP\Util::demoIsEnabled()) {
        SP\Response::printJSON(_('Ey, esto es una DEMO!!'));
    }
    //    ConfigDB::readConfig();
    ConfigDB::setCacheConfigValue('masterPwd', $hashMPass);
    ConfigDB::setCacheConfigValue('lastupdatempass', time());
    if (ConfigDB::writeConfig()) {
        SP\Log::writeNewLogAndEmail(_('Actualizar Clave Maestra'));
        SP\Response::printJSON(_('Clave maestra actualizada'), 0);
    } else {
        SP\Response::printJSON(_('Error al guardar el hash de la clave maestra'));
    }
} elseif ($actionId === SP\Controller\ActionsInterface::ACTION_CFG_ENCRYPTION_TEMPPASS) {
    $tempMasterMaxTime = SP\Request::analyze('tmpass_maxtime', 3600);
    $tempMasterPass = CryptMasterPass::setTempMasterPass($tempMasterMaxTime);
    if ($tempMasterPass !== false && !empty($tempMasterPass)) {
        SP\Email::sendEmail(new \SP\Log(_('Generar Clave Temporal'), SP\Html::strongText(_('Clave') . ': ') . $tempMasterPass));
        SP\Response::printJSON(_('Clave Temporal Generada'), 0, $doActionOnClose);
    } else {
        SP\Response::printJSON(_('Error al generar clave temporal'));
    }
} else {
    SP\Response::printJSON(_('Acción Inválida'));