Current File : /var/www/pediatribu/wp-content/plugins/webp-express/lib/classes/SanityCheck.php
<?php

namespace WebPExpress;

use \WebPExpress\PathHelper;
use \WebPExpress\Sanitize;
use \WebPExpress\SanityException;

class SanityCheck
{

    private static function fail($errorMsg, $input)
    {
        // sanitize input before calling error_log(), it might be sent to file, mail, syslog etc.
        //error_log($errorMsg . '. input:' . Sanitize::removeNUL($input) . 'backtrace: ' . print_r(debug_backtrace(), true));
        error_log($errorMsg . '. input:' . Sanitize::removeNUL($input));

        //error_log(get_magic_quotes_gpc() ? 'on' :'off');
        throw new SanityException($errorMsg);   //  . '. Check debug.log for details (and make sure debugging is enabled)'
    }


    /**
     *
     *  @param  string  $input  string to test for NUL char
     */
    public static function mustBeString($input, $errorMsg = 'String expected')
    {
        if (gettype($input) !== 'string') {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    /**
     *  The NUL character is a demon, because it can be used to bypass other tests
     *  See https://st-g.de/2011/04/doing-filename-checks-securely-in-PHP.
     *
     *  @param  string  $input  string to test for NUL char
     */
    public static function noNUL($input, $errorMsg = 'NUL character is not allowed')
    {
        self::mustBeString($input);
        if (strpos($input, chr(0)) !== false) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    /**
     *  Prevent control chararters (#00 - #20).
     *
     *  This prevents line feed, new line, tab, charater return, tab, ets.
     *  https://www.rapidtables.com/code/text/ascii-table.html
     *
     *  @param  string  $input  string to test for control characters
     */
    public static function noControlChars($input, $errorMsg = 'Control characters are not allowed')
    {
        self::mustBeString($input);
        self::noNUL($input);
        if (preg_match('#[\x{0}-\x{1f}]#', $input)) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }


    /**
     *
     *  @param  mixed  $input  something that may not be empty
     */
    public static function notEmpty($input, $errorMsg = 'Must be non-empty')
    {
        if (empty($input)) {
            self::fail($errorMsg, '');
        }
        return $input;
    }



    public static function noDirectoryTraversal($input, $errorMsg = 'Directory traversal is not allowed')
    {
        self::mustBeString($input);
        self::noControlChars($input);
        if (preg_match('#\.\.\/#', $input)) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    public static function noStreamWrappers($input, $errorMsg = 'Stream wrappers are not allowed')
    {
        self::mustBeString($input);
        self::noControlChars($input);

        // Prevent stream wrappers ("phar://", "php://" and the like)
        // https://www.php.net/manual/en/wrappers.phar.php
        if (preg_match('#^\\w+://#', Sanitize::removeNUL($input))) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    public static function pathDirectoryTraversalAllowed($input)
    {
        self::notEmpty($input);
        self::mustBeString($input);
        self::noControlChars($input);
        self::noStreamWrappers($input);

        // PS: The following sanitize has no effect, as we have just tested that there are no NUL and
        // no stream wrappers. It is here to avoid false positives on coderisk.com
        $input = Sanitize::path($input);

        return $input;
    }

    public static function pathWithoutDirectoryTraversal($input)
    {
        self::pathDirectoryTraversalAllowed($input);
        self::noDirectoryTraversal($input);
        $input = Sanitize::path($input);

        return $input;
    }

    public static function path($input)
    {
        return self::pathWithoutDirectoryTraversal($input);
    }


    /**
     *  Beware: This does not take symlinks into account.
     *  I should make one that does. Until then, you should probably not call this method from outside this class
     */
    private static function pathBeginsWith($input, $beginsWith, $errorMsg = 'Path is outside allowed path')
    {
        self::path($input);
        if (!(strpos($input, $beginsWith) === 0)) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    private static function pathBeginsWithSymLinksExpanded($input, $beginsWith, $errorMsg = 'Path is outside allowed path') {
        $closestExistingFolder = PathHelper::findClosestExistingFolderSymLinksExpanded($input);
        self::pathBeginsWith($closestExistingFolder, $beginsWith, $errorMsg);
    }

    private static function absPathMicrosoftStyle($input, $errorMsg = 'Not an fully qualified Windows path')
    {
        // On microsoft we allow [drive letter]:\
        if (!preg_match("#^[A-Z]:\\\\|/#", $input)) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    private static function isOnMicrosoft()
    {
        if (isset($_SERVER['SERVER_SOFTWARE'])) {
            if (strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'microsoft') !== false) {
                return true;
            }
        }
        switch (PHP_OS) {
            case "WINNT":
            case "WIN32":
            case "INTERIX":
            case "UWIN":
            case "UWIN-W7":
                return true;
                break;
        }
        return false;
    }

    public static function absPath($input, $errorMsg = 'Not an absolute path')
    {
        // first make sure there are no nasty things like control chars, phar wrappers, etc.
        // - and no directory traversal either.
        self::path($input);

        // For non-windows, we require that an absolute path begins with "/"
        // On windows, we also accept that a path starts with a drive letter, ie "C:\"
        if ((strpos($input, '/') !== 0)) {
            if (self::isOnMicrosoft()) {
                self::absPathMicrosoftStyle($input);
            } else {
                self::fail($errorMsg, $input);
            }
        }
        return $input;
    }



    public static function absPathInOneOfTheseRoots()
    {

    }


    /**
     * Look if filepath is within a dir path.
     * Also tries expanding symlinks
     *
     * @param  string  $filePath   Path to file. It may be non-existing.
     * @param  string  $dirPath    Path to dir. It must exist in order for symlinks to be expanded.
     */
    private static function isFilePathWithinExistingDirPath($filePath, $dirPath)
    {
        // sanity-check input. It must be a valid absolute filepath. It is allowed to be non-existing
        self::absPath($filePath);

        // sanity-check dir and that it exists.
        self::absPathExistsAndIsDir($dirPath);

        return PathHelper::isFilePathWithinDirPath($filePath, $dirPath);
    }

    /**
     * Look if filepath is within multiple dir paths.
     * Also tries expanding symlinks
     *
     * @param  string  $input    Path to file. It may be non-existing.
     * @param  array   $roots    Allowed root dirs. Note that they must exist in order for symlinks to be expanded.
     */
    public static function filePathWithinOneOfTheseRoots($input, $roots, $errorMsg = 'The path is outside allowed roots.')
    {
        self::absPath($input);

        foreach ($roots as $root) {
            if (self::isFilePathWithinExistingDirPath($input, $root)) {
                return $input;
            }
        }
        self::fail($errorMsg, $input);
    }

    /*
    public static function sourcePath($input, $errorMsg = 'The source path is outside allowed roots. It is only allowed to convert images that resides in: home dir, content path, upload dir and plugin dir.')
    {
        $validPaths = [
            Paths::getHomeDirAbs(),
            Paths::getIndexDirAbs(),
            Paths::getContentDirAbs(),
            Paths::getUploadDirAbs(),
            Paths::getPluginDirAbs()
        ];
        return self::filePathWithinOneOfTheseRoots($input, $validPaths, $errorMsg);
    }

    public static function destinationPath($input, $errorMsg = 'The destination path is outside allowed roots. The webps may only be stored in the upload folder and in the folder that WebP Express stores converted images in')
    {
        self::absPath($input);

        // Webp Express only store converted images in upload folder and in its "webp-images" folder
        // Check that destination path is within one of these.
        $validPaths = [
            '/var/www/webp-express-tests/we1'
            //Paths::getUploadDirAbs(),
            //Paths::getWebPExpressContentDirRel() . '/webp-images'
        ];
        return self::filePathWithinOneOfTheseRoots($input, $validPaths, $errorMsg);
    }*/


    /**
     * Test that path is an absolute path and it is in document root.
     *
     * If DOCUMENT_ROOT is not available, then only the absPath check will be done.
     *
     * TODO: Instead of this method, we shoud check
     *
     *
     * It is acceptable if the absolute path does not exist
     */
    public static function absPathIsInDocRoot($input, $errorMsg = 'Path is outside document root')
    {
        self::absPath($input);

        if (!isset($_SERVER["DOCUMENT_ROOT"])) {
            return $input;
        }
        if ($_SERVER["DOCUMENT_ROOT"] == '') {
            return $input;
        }

        $docRoot = self::absPath($_SERVER["DOCUMENT_ROOT"]);
        $docRoot = rtrim($docRoot, '/');

        try {
            $docRoot = self::absPathExistsAndIsDir($docRoot);
        } catch (SanityException $e) {
            return $input;
        }

        // Use realpath to expand symbolic links and check if it exists
        $docRootSymLinksExpanded = @realpath($docRoot);
        if ($docRootSymLinksExpanded === false) {
            // probably outside open basedir restriction.
            //$errorMsg = 'Cannot resolve document root';
            //self::fail($errorMsg, $input);

            // Cannot resolve document root, so cannot test if in document root
            return $input;
        }

        // See if $filePath begins with the realpath of the $docRoot + '/'. If it does, we are done and OK!
        // (pull #429)
        if (strpos($input, $docRootSymLinksExpanded . '/') === 0) {
            return $input;
        }

        $docRootSymLinksExpanded = rtrim($docRootSymLinksExpanded, '\\/');
        $docRootSymLinksExpanded = self::absPathExists($docRootSymLinksExpanded, 'Document root does not exist!');
        $docRootSymLinksExpanded = self::absPathExistsAndIsDir($docRootSymLinksExpanded, 'Document root is not a directory!');

        $directorySeparator = self::isOnMicrosoft() ? '\\' : '/';
        $errorMsg = 'Path is outside resolved document root (' . $docRootSymLinksExpanded . ')';
        self::pathBeginsWithSymLinksExpanded($input, $docRootSymLinksExpanded . $directorySeparator, $errorMsg);

        return $input;
    }

    public static function absPathExists($input, $errorMsg = 'Path does not exist or it is outside restricted basedir')
    {
        self::absPath($input);
        if (@!file_exists($input)) {
            // TODO: We might be able to detect if the problem is that the path does not exist or if the problem
            // is that it is outside restricted basedir.
            // ie by creating an error handler or inspecting the php ini "open_basedir" setting
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    public static function absPathExistsAndIsDir(
        $input,
        $errorMsg = 'Path points to a file (it should point to a directory)'
    ) {
        self::absPathExists($input, 'Directory does not exist or is outside restricted basedir');
        if (!is_dir($input)) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    public static function absPathExistsAndIsFile(
        $input,
        $errorMsg = 'Path points to a directory (it should not do that)'
    ) {
        self::absPathExists($input, 'File does not exist or is outside restricted basedir');
        if (@is_dir($input)) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    public static function absPathExistsAndIsFileInDocRoot($input)
    {
        self::absPathExistsAndIsFile($input);
        self::absPathIsInDocRoot($input);
        return $input;
    }

    public static function absPathExistsAndIsNotDir(
        $input,
        $errorMsg = 'Path points to a directory (it should point to a file)'
    ) {
        self::absPathExistsAndIsFile($input, $errorMsg);
        return $input;
    }


    public static function pregMatch($pattern, $input, $errorMsg = 'Does not match expected pattern')
    {
        self::noNUL($input);
        self::mustBeString($input);
        if (!preg_match($pattern, $input)) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    public static function isJSONArray($input, $errorMsg = 'Not a JSON array')
    {
        self::noNUL($input);
        self::mustBeString($input);
        self::notEmpty($input);
        if ((strpos($input, '[') !== 0) || (!is_array(json_decode($input)))) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

    public static function isJSONObject($input, $errorMsg = 'Not a JSON object')
    {
        self::noNUL($input);
        self::mustBeString($input);
        self::notEmpty($input);
        if ((strpos($input, '{') !== 0) || (!is_object(json_decode($input)))) {
            self::fail($errorMsg, $input);
        }
        return $input;
    }

}
¿Qué es la limpieza dental de perros? - Clínica veterinaria


Es la eliminación del sarro y la placa adherida a la superficie de los dientes mediante un equipo de ultrasonidos que garantiza la integridad de las piezas dentales a la vez que elimina en profundidad cualquier resto de suciedad.

A continuación se procede al pulido de los dientes mediante una fresa especial que elimina la placa bacteriana y devuelve a los dientes el aspecto sano que deben tener.

Una vez terminado todo el proceso, se mantiene al perro en observación hasta que se despierta de la anestesia, bajo la atenta supervisión de un veterinario.

¿Cada cuánto tiempo tengo que hacerle una limpieza dental a mi perro?

A partir de cierta edad, los perros pueden necesitar una limpieza dental anual o bianual. Depende de cada caso. En líneas generales, puede decirse que los perros de razas pequeñas suelen acumular más sarro y suelen necesitar una atención mayor en cuanto a higiene dental.


Riesgos de una mala higiene


Los riesgos más evidentes de una mala higiene dental en los perros son los siguientes:

  • Cuando la acumulación de sarro no se trata, se puede producir una inflamación y retracción de las encías que puede descalzar el diente y provocar caídas.
  • Mal aliento (halitosis).
  • Sarro perros
  • Puede ir a más
  • Las bacterias de la placa pueden trasladarse a través del torrente circulatorio a órganos vitales como el corazón ocasionando problemas de endocarditis en las válvulas. Las bacterias pueden incluso acantonarse en huesos (La osteomielitis es la infección ósea, tanto cortical como medular) provocando mucho dolor y una artritis séptica).

¿Cómo se forma el sarro?

El sarro es la calcificación de la placa dental. Los restos de alimentos, junto con las bacterias presentes en la boca, van a formar la placa bacteriana o placa dental. Si la placa no se retira, al mezclarse con la saliva y los minerales presentes en ella, reaccionará formando una costra. La placa se calcifica y se forma el sarro.

El sarro, cuando se forma, es de color blanquecino pero a medida que pasa el tiempo se va poniendo amarillo y luego marrón.

Síntomas de una pobre higiene dental
La señal más obvia de una mala salud dental canina es el mal aliento.

Sin embargo, a veces no es tan fácil de detectar
Y hay perros que no se dejan abrir la boca por su dueño. Por ejemplo…

Recientemente nos trajeron a la clínica a un perro que parpadeaba de un ojo y decía su dueño que le picaba un lado de la cara. Tenía molestias y dificultad para comer, lo que había llevado a sus dueños a comprarle comida blanda (que suele ser un poco más cara y llevar más contenido en grasa) durante medio año. Después de una exploración oftalmológica, nos dimos cuenta de que el ojo tenía una úlcera en la córnea probablemente de rascarse . Además, el canto lateral del ojo estaba inflamado. Tenía lo que en humanos llamamos flemón pero como era un perro de pelo largo, no se le notaba a simple vista. Al abrirle la boca nos llamó la atención el ver una muela llena de sarro. Le realizamos una radiografía y encontramos una fístula que llegaba hasta la parte inferior del ojo.

Le tuvimos que extraer la muela. Tras esto, el ojo se curó completamente con unos colirios y una lentilla protectora de úlcera. Afortunadamente, la úlcera no profundizó y no perforó el ojo. Ahora el perro come perfectamente a pesar de haber perdido una muela.

¿Cómo mantener la higiene dental de tu perro?
Hay varias maneras de prevenir problemas derivados de la salud dental de tu perro.

Limpiezas de dientes en casa
Es recomendable limpiar los dientes de tu perro semanal o diariamente si se puede. Existe una gran variedad de productos que se pueden utilizar:

Pastas de dientes.
Cepillos de dientes o dedales para el dedo índice, que hacen más fácil la limpieza.
Colutorios para echar en agua de bebida o directamente sobre el diente en líquido o en spray.

En la Clínica Tus Veterinarios enseñamos a nuestros clientes a tomar el hábito de limpiar los dientes de sus perros desde que son cachorros. Esto responde a nuestro compromiso con la prevención de enfermedades caninas.

Hoy en día tenemos muchos clientes que limpian los dientes todos los días a su mascota, y como resultado, se ahorran el dinero de hacer limpiezas dentales profesionales y consiguen una mejor salud de su perro.


Limpiezas dentales profesionales de perros y gatos

Recomendamos hacer una limpieza dental especializada anualmente. La realizamos con un aparato de ultrasonidos que utiliza agua para quitar el sarro. Después, procedemos a pulir los dientes con un cepillo de alta velocidad y una pasta especial. Hacemos esto para proteger el esmalte.

La frecuencia de limpiezas dentales necesaria varía mucho entre razas. En general, las razas grandes tienen buena calidad de esmalte, por lo que no necesitan hacerlo tan a menudo e incluso pueden pasarse la vida sin requerir una limpieza. Sin embargo, razas pequeñas como el Yorkshire o el Maltés, deben hacérselas todos los años desde cachorros si se quiere conservar sus piezas dentales.

Otro factor fundamental es la calidad del pienso. Algunas marcas han diseñado croquetas que limpian la superficie del diente y de la muela al masticarse.

Ultrasonido para perros

¿Se necesita anestesia para las limpiezas dentales de perros y gatos?

La limpieza dental en perros no es una técnica que pueda practicarse sin anestesia general , aunque hay veces que los propietarios no quieren anestesiar y si tiene poco sarro y el perro es muy bueno se puede intentar…… , pero no se va a poder pulir ni acceder a todas la zona de la boca …. Además los limpiadores dentales van a irrigar agua y hay riesgo de aspiración a vías respiratorias si no se realiza una anestesia correcta con intubación traqueal . En resumen , sin anestesia no se va hacer una correcta limpieza dental.

Tampoco sirve la sedación ya que necesitamos que el animal esté totalmente quieto, y el veterinario tenga un acceso completo a todas sus piezas dentales y encías.

Alimentos para la limpieza dental

Hay que tener cierto cuidado a la hora de comprar determinados alimentos porque no todos son saludables. Algunos tienen demasiado contenido graso, que en exceso puede causar problemas cardiovasculares y obesidad.

Los mejores alimentos para los dientes son aquellos que están elaborados por empresas farmacéuticas y llevan componentes químicos con tratamientos específicos para el diente del perro. Esto implica no solo limpieza a través de la acción mecánica de morder sino también un tratamiento antibacteriano para prevenir el sarro.

Conclusión

Si eres como la mayoría de dueños, por falta de tiempo , es probable que no estés prestando la suficiente atención a la limpieza dental de tu perro. Por eso te animamos a que comiences a limpiar los dientes de tu perro y consideres atender a su higiene bucal con frecuencia.

Estas simples medidas pueden conllevar a que tu perro tenga una vida más larga y mucho más saludable.

Si te resulta imposible introducir un cepillo de dientes a tu perro en la boca, pásate con él por clínica Tus Veterinarios y te explicamos cómo hacerlo.

Necesitas hacer una limpieza dental profesional a tu mascota?
Llámanos al 622575274 o contacta con nosotros

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

¡Hola!