diff --git a/inc/SP/Auth/Ldap/LdapBase.class.php b/inc/SP/Auth/Ldap/LdapBase.class.php index ec522d4a..da9d6158 100644 --- a/inc/SP/Auth/Ldap/LdapBase.class.php +++ b/inc/SP/Auth/Ldap/LdapBase.class.php @@ -337,16 +337,6 @@ abstract class LdapBase implements LdapInterface, AuthInterface $this->serverPort = $this->getServerPort(); } - /** - * Devolver el puerto del servidor si está establecido - * - * @return int - */ - protected function getServerPort() - { - return preg_match('/[\d\.]+:(\d+)/', $this->server, $port) ? $port[1] : 389; - } - /** * @return string */ @@ -482,6 +472,16 @@ abstract class LdapBase implements LdapInterface, AuthInterface return true; } + /** + * Devolver el puerto del servidor si está establecido + * + * @return int + */ + protected function getServerPort() + { + return preg_match('/[\d\.]+:(\d+)/', $this->server, $port) ? $port[1] : 389; + } + /** * Obtener el servidor de LDAP a utilizar * diff --git a/inc/SP/Controller/ItemShowController.class.php b/inc/SP/Controller/ItemShowController.class.php index 580886ef..3adc52f4 100644 --- a/inc/SP/Controller/ItemShowController.class.php +++ b/inc/SP/Controller/ItemShowController.class.php @@ -520,10 +520,6 @@ class ItemShowController extends ControllerBase implements ActionsInterface, Ite throw new ItemException(__('Clave maestra actualizada') . '
' . __('Reinicie la sesión para cambiarla')); } - if (!UserPass::checkUserUpdateMPass(Session::getUserData()->getUserId())) { - throw new ItemException(__('Clave maestra actualizada', false) . '
' . __('Reinicie la sesión para cambiarla', false)); - } - $key = CryptSession::getSessionKey(); $securedKey = Crypt::unlockSecuredKey($AccountData->getAccountKey(), $key); $accountClearPass = Crypt::decrypt($AccountData->getAccountPass(), $securedKey, $key); diff --git a/inc/SP/Controller/MainController.class.php b/inc/SP/Controller/MainController.class.php index 67451d59..c1bc6880 100644 --- a/inc/SP/Controller/MainController.class.php +++ b/inc/SP/Controller/MainController.class.php @@ -68,8 +68,8 @@ class MainController extends ControllerBase implements ActionsInterface * Constructor * * @param $template Template con instancia de plantilla - * @param string $page El nombre de página para la clase del body - * @param bool $initialize Si es una inicialización completa + * @param string $page El nombre de página para la clase del body + * @param bool $initialize Si es una inicialización completa */ public function __construct(Template $template = null, $page = '', $initialize = true) { diff --git a/inc/SP/Http/Request.class.php b/inc/SP/Http/Request.class.php index 58eb1256..57006180 100644 --- a/inc/SP/Http/Request.class.php +++ b/inc/SP/Http/Request.class.php @@ -35,6 +35,8 @@ use SP\Html\Html; */ class Request { + private static $secureDirs = ['css', 'js']; + /** * Comprobar el método utilizado para enviar un formulario. * @@ -55,6 +57,48 @@ class Request } } + /** + * Devolver las cabeceras enviadas desde el cliente. + * + * @param string $header nombre de la cabecera a devolver + * @return array|string + */ + public static function getRequestHeaders($header = '') + { + if (!empty($header)) { + $header = strpos($header, 'HTTP_') === false ? 'HTTP_' . str_replace('-', '_', strtoupper($header)) : $header; + + return isset($_SERVER[$header]) ? $_SERVER[$header] : ''; + } + + return self::getApacheHeaders(); + } + + /** + * Función que sustituye a apache_request_headers + * + * @return array + */ + private static function getApacheHeaders() + { + if (function_exists('\apache_request_headers')) { + return apache_request_headers(); + } + + $headers = []; + + foreach ($_SERVER as $key => $value) { + if (strpos($key, 'HTTP_') === 0) { + $key = ucwords(strtolower(str_replace('_', '-', substr($key, 5))), '-'); + $headers[$key] = $value; + } else { + $headers[$key] = $value; + } + } + + return $headers; + } + /** * Analizar un valor encriptado y devolverlo desencriptado * @@ -142,48 +186,6 @@ class Request return (self::getRequestHeaders('Cache-Control') === 'max-age=0'); } - /** - * Devolver las cabeceras enviadas desde el cliente. - * - * @param string $header nombre de la cabecera a devolver - * @return array|string - */ - public static function getRequestHeaders($header = '') - { - if (!empty($header)) { - $header = strpos($header, 'HTTP_') === false ? 'HTTP_' . str_replace('-', '_', strtoupper($header)) : $header; - - return isset($_SERVER[$header]) ? $_SERVER[$header] : ''; - } - - return self::getApacheHeaders(); - } - - /** - * Función que sustituye a apache_request_headers - * - * @return array - */ - private static function getApacheHeaders() - { - if (function_exists('\apache_request_headers')) { - return apache_request_headers(); - } - - $headers = []; - - foreach ($_SERVER as $key => $value) { - if (strpos($key, 'HTTP_') === 0) { - $key = ucwords(strtolower(str_replace('_', '-', substr($key, 5))), '-'); - $headers[$key] = $value; - } else { - $headers[$key] = $value; - } - } - - return $headers; - } - /** * Comprobar si existen parámetros pasados por POST para enviarlos por GET */ @@ -218,22 +220,26 @@ class Request /** * Devolver una ruta segura para * - * @param $path - * @param null $base + * @param $path + * @param string $base * @return string */ public static function getSecureAppPath($path, $base = null) { if ($base === null) { $base = Init::$SERVERROOT; + } elseif (!in_array(basename($base), self::$secureDirs, true)) { + return ''; } $realPath = realpath($base . DIRECTORY_SEPARATOR . $path); - if ($realPath === false || strpos($realPath, $base) !== 0) { + if ($realPath === false + || strpos($realPath, $base) !== 0 + ) { return ''; - } else { - return $realPath; } + + return $realPath; } } \ No newline at end of file diff --git a/inc/SP/Util/Util.class.php b/inc/SP/Util/Util.class.php index 001184fa..81194d50 100644 --- a/inc/SP/Util/Util.class.php +++ b/inc/SP/Util/Util.class.php @@ -407,8 +407,8 @@ class Util */ public static function getVersion($retBuild = false, $normalized = false) { - $build = 17042601; - $version = [2, 2, 0]; + $build = 17040401; + $version = [2, 1, 5]; if ($normalized === true) { return [implode('', $version), $build];