/** * Comprobar si es necesario limpiar el registro de eventos */ public function checkClear() { if ($this->view->clear && $this->view->sk && SessionUtil::checkSessionKey($this->view->sk)) { if (\SP\Log::clearEvents()) { \SP\Response::printJSON(_('Registro de eventos vaciado'), 0, "sysPassUtil.Common.doAction(" . ActionsInterface::ACTION_EVL . "); sysPassUtil.Common.scrollUp();"); } else { \SP\Response::printJSON(_('Error al vaciar el registro de eventos')); } } }
/** * Obtener los datos para la ficha de tokens de API */ public function getToken() { $this->view->addTemplate('tokens'); $token = \SP\ApiTokens::getTokens($this->view->itemId, true); $this->view->assign('users', \SP\DB::getValuesForSelect('usrData', 'user_id', 'user_name')); $this->view->assign('actions', \SP\ApiTokens::getTokenActions()); $this->view->assign('token', $token); $this->view->assign('gotData', is_object($token)); if ($this->view->isView === true) { $msg = sprintf('%s ;;Usuario: %s', _('Token de autorización visualizado'), $token->user_login); Log::writeNewLogAndEmail(_('Autorizaciones'), $msg); } }
/** * 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; } }
/** * Eliminar token * * @throws SPException */ public function deleteToken() { $query = 'DELETE FROM authTokens WHERE authtoken_id = :id LIMIT 1'; $data['id'] = $this->_tokenId; try { DB::getQuery($query, __FUNCTION__, $data); } catch (SPException $e) { throw new SPException(SPException::SP_CRITICAL, _('Error interno')); } $Log = new Log(_('Eliminar Autorización')); $Log->addDescription(sprintf('%d', $this->_tokenId)); $Log->writeLog(); Email::sendEmail($Log); }
$userLogin = SP\Request::analyze('login'); $userEmail = SP\Request::analyze('email'); $userPass = SP\Request::analyzeEncrypted('pass'); $userPassR = SP\Request::analyzeEncrypted('passR'); $hash = SP\Request::analyze('hash'); $time = SP\Request::analyze('time'); $message['action'] = _('Recuperación de Clave'); if ($userLogin && $userEmail) { $log = new \SP\Log(_('Recuperación de Clave')); if (SP\Auth::mailPassRecover($userLogin, $userEmail)) { $log->addDescription(SP\Html::strongText(_('Solicitado para') . ': ') . ' ' . $userLogin . ' (' . $userEmail . ')'); SP\Response::printJSON(_('Solicitud enviada') . ';;' . _('En breve recibirá un correo para completar la solicitud.'), 0, 'goLogin();'); } else { $log->addDescription('ERROR'); $log->addDescription(SP\Html::strongText(_('Solicitado para') . ': ') . ' ' . $userLogin . ' (' . $userEmail . ')'); SP\Response::printJSON(_('No se ha podido realizar la solicitud. Consulte con el administrador.')); } $log->writeLog(); SP\Email::sendEmail($log); } elseif ($userPass && $userPassR && $userPass === $userPassR) { $userId = UserPassRecover::checkHashPassRecover($hash); if ($userId) { if (UserPass::updateUserPass($userId, $userPass) && UserPassRecover::updateHashPassRecover($hash)) { \SP\Log::writeNewLogAndEmail(_('Modificar Clave Usuario'), SP\Html::strongText(_('Login') . ': ') . UserUtil::getUserLoginById($userId)); SP\Response::printJSON(_('Clave actualizada'), 0, 'goLogin();'); } } SP\Response::printJSON(_('Error al modificar la clave')); } else { SP\Response::printJSON(_('La clave es incorrecta o no coincide')); }