/** * Comrpueba y actualiza la versión de la aplicación. */ private static function checkVersion() { if (substr(self::$_SUBURI, -9) != 'index.php' || Request::analyze('logout', 0) === 1) { return; } $update = false; $configVersion = (int) str_replace('.', '', Config::getValue('version')); $databaseVersion = (int) str_replace('.', '', ConfigDB::getValue('version')); $appVersion = (int) implode(Util::getVersion(true)); if ($databaseVersion < $appVersion && Request::analyze('nodbupgrade', 0) === 0) { if (Upgrade::needDBUpgrade($databaseVersion)) { if (!self::checkMaintenanceMode(true)) { if (Config::getValue('upgrade_key', 0) === 0) { Config::setValue('upgrade_key', sha1(uniqid(mt_rand(), true))); Config::setValue('maintenance', true); } self::initError(_('La aplicación necesita actualizarse'), sprintf(_('Si es un administrador pulse en el enlace: %s'), '<a href="index.php?upgrade=1&a=upgrade">' . _('Actualizar') . '</a>')); } $action = Request::analyze('a'); $hash = Request::analyze('h'); if ($action === 'upgrade' && $hash === Config::getValue('upgrade_key', 0)) { if (Upgrade::doUpgrade($databaseVersion)) { ConfigDB::setValue('version', $appVersion); Config::setValue('maintenance', false); Config::deleteParam('upgrade_key'); $update = true; } } else { $controller = new Controller\MainC(); $controller->getUpgrade(); $controller->view(); exit; } } } if ($configVersion < $appVersion && Upgrade::needConfigUpgrade($appVersion) && Upgrade::upgradeConfig($appVersion)) { Config::setValue('version', $appVersion); $update = true; } if ($update === true) { $log = new Log(_('Actualización')); $log->addDescription(_('Actualización de versión realizada.')); $log->addDescription(_('Versión') . ': ' . $appVersion); $log->writeLog(); Email::sendEmail($log); self::$UPDATED = true; } }
/** * Obtener la pestaña de encriptación * * @return bool */ public function getEncryptionTab() { $this->setAction(self::ACTION_CFG_ENCRYPTION); if (!$this->checkAccess()) { return; } $this->view->addTemplate('encryption'); $this->view->assign('lastUpdateMPass', ConfigDB::getValue("lastupdatempass")); $this->view->assign('tempMasterPassTime', ConfigDB::getValue("tempmaster_passtime")); $this->view->assign('tempMasterMaxTime', ConfigDB::getValue("tempmaster_maxtime")); $this->view->assign('tempMasterPass', Session::getTemporaryMasterPass()); $this->view->append('tabs', array('title' => _('Encriptación'))); $this->view->assign('tabIndex', $this->getTabIndex(), 'encryption'); }
} $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 {