/** * 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'); }
$newMasterPass = SP\Request::analyzeEncrypted('newMasterPwd'); $newMasterPassR = SP\Request::analyzeEncrypted('newMasterPwdR'); $confirmPassChange = SP\Request::analyze('confirmPassChange', 0, false, 1); $noAccountPassChange = SP\Request::analyze('chkNoAccountChange', 0, false, 1); if (!UserPass::checkUserUpdateMPass()) { SP\Response::printJSON(_('Clave maestra actualizada') . ';;' . _('Reinicie la sesión para cambiarla')); } elseif ($newMasterPass == '' && $currentMasterPass == '') { SP\Response::printJSON(_('Clave maestra no indicada')); } elseif ($confirmPassChange == 0) { SP\Response::printJSON(_('Se ha de confirmar el cambio de clave')); } if ($newMasterPass == $currentMasterPass) { SP\Response::printJSON(_('Las claves son idénticas')); } elseif ($newMasterPass != $newMasterPassR) { SP\Response::printJSON(_('Las claves maestras no coinciden')); } elseif (!SP\Crypt::checkHashPass($currentMasterPass, ConfigDB::getValue('masterPwd'), true)) { SP\Response::printJSON(_('La clave maestra actual no coincide')); } $hashMPass = SP\Crypt::mkHashPassword($newMasterPass); if (!$noAccountPassChange) { $Account = new SP\Account(); if (!$Account->updateAccountsMasterPass($currentMasterPass, $newMasterPass)) { SP\Response::printJSON(_('Errores al actualizar las claves de las cuentas')); } $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')); }