!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/main_file/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engine/   drwxr-xr-x
Free 13 GB of 57.97 GB (22.43%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     FormattedNumber.php (5.53 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace PhpOffice\PhpSpreadsheet\Calculation\Engine;

use 
PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use 
PhpOffice\PhpSpreadsheet\Shared\StringHelper;

class 
FormattedNumber
{
    
/**    Constants                */
    /**    Regular Expressions        */
    
private const STRING_REGEXP_FRACTION '~^\s*(-?)((\d*)\s+)?(\d+\/\d+)\s*$~';

    private const 
STRING_REGEXP_PERCENT '~^(?:(?: *(?<PrefixedSign>[-+])? *\% *(?<PrefixedSign2>[-+])? *(?<PrefixedValue>[0-9]+\.?[0-9*]*(?:E[-+]?[0-9]*)?) *)|(?: *(?<PostfixedSign>[-+])? *(?<PostfixedValue>[0-9]+\.?[0-9]*(?:E[-+]?[0-9]*)?) *\% *))$~i';

    
// preg_quoted string for major currency symbols, with a %s for locale currency
    
private const CURRENCY_CONVERSION_LIST '\$€£¥%s';

    private const 
STRING_CONVERSION_LIST = [
        [
self::class, 'convertToNumberIfNumeric'],
        [
self::class, 'convertToNumberIfFraction'],
        [
self::class, 'convertToNumberIfPercent'],
        [
self::class, 'convertToNumberIfCurrency'],
    ];

    
/**
     * Identify whether a string contains a formatted numeric value,
     * and convert it to a numeric if it is.
     *
     * @param string $operand string value to test
     */
    
public static function convertToNumberIfFormatted(string &$operand): bool
    
{
        foreach (
self::STRING_CONVERSION_LIST as $conversionMethod) {
            if (
$conversionMethod($operand) === true) {
                return 
true;
            }
        }

        return 
false;
    }

    
/**
     * Identify whether a string contains a numeric value,
     * and convert it to a numeric if it is.
     *
     * @param string $operand string value to test
     */
    
public static function convertToNumberIfNumeric(string &$operand): bool
    
{
        
$thousandsSeparator preg_quote(StringHelper::getThousandsSeparator());
        
$value preg_replace(['/(\d)' $thousandsSeparator '(\d)/u''/([+-])\s+(\d)/u'], ['$1$2''$1$2'], trim($operand));
        
$decimalSeparator preg_quote(StringHelper::getDecimalSeparator());
        
$value preg_replace(['/(\d)' $decimalSeparator '(\d)/u''/([+-])\s+(\d)/u'], ['$1.$2''$1$2'], $value ?? '');

        if (
is_numeric($value)) {
            
$operand = (float) $value;

            return 
true;
        }

        return 
false;
    }

    
/**
     * Identify whether a string contains a fractional numeric value,
     * and convert it to a numeric if it is.
     *
     * @param string $operand string value to test
     */
    
public static function convertToNumberIfFraction(string &$operand): bool
    
{
        if (
preg_match(self::STRING_REGEXP_FRACTION$operand$match)) {
            
$sign = ($match[1] === '-') ? '-' '+';
            
$wholePart = ($match[3] === '') ? '' : ($sign $match[3]);
            
$fractionFormula '=' $wholePart $sign $match[4];
            
$operand Calculation::getInstance()->_calculateFormulaValue($fractionFormula);

            return 
true;
        }

        return 
false;
    }

    
/**
     * Identify whether a string contains a percentage, and if so,
     * convert it to a numeric.
     *
     * @param string $operand string value to test
     */
    
public static function convertToNumberIfPercent(string &$operand): bool
    
{
        
$thousandsSeparator preg_quote(StringHelper::getThousandsSeparator());
        
$value preg_replace('/(\d)' $thousandsSeparator '(\d)/u''$1$2'trim($operand));
        
$decimalSeparator preg_quote(StringHelper::getDecimalSeparator());
        
$value preg_replace(['/(\d)' $decimalSeparator '(\d)/u''/([+-])\s+(\d)/u'], ['$1.$2''$1$2'], $value ?? '');

        
$match = [];
        if (
$value !== null && preg_match(self::STRING_REGEXP_PERCENT$value$matchPREG_UNMATCHED_AS_NULL)) {
            
//Calculate the percentage
            
$sign = ($match['PrefixedSign'] ?? $match['PrefixedSign2'] ?? $match['PostfixedSign']) ?? '';
            
$operand = (float) ($sign . ($match['PostfixedValue'] ?? $match['PrefixedValue'])) / 100;

            return 
true;
        }

        return 
false;
    }

    
/**
     * Identify whether a string contains a currency value, and if so,
     * convert it to a numeric.
     *
     * @param string $operand string value to test
     */
    
public static function convertToNumberIfCurrency(string &$operand): bool
    
{
        
$currencyRegexp self::currencyMatcherRegexp();
        
$thousandsSeparator preg_quote(StringHelper::getThousandsSeparator());
        
$value preg_replace('/(\d)' $thousandsSeparator '(\d)/u''$1$2'$operand);

        
$match = [];
        if (
$value !== null && preg_match($currencyRegexp$value$matchPREG_UNMATCHED_AS_NULL)) {
            
//Determine the sign
            
$sign = ($match['PrefixedSign'] ?? $match['PrefixedSign2'] ?? $match['PostfixedSign']) ?? '';
            
//Cast to a float
            
$operand = (float) ($sign . ($match['PostfixedValue'] ?? $match['PrefixedValue']));

            return 
true;
        }

        return 
false;
    }

    public static function 
currencyMatcherRegexp(): string
    
{
        
$currencyCodes sprintf(self::CURRENCY_CONVERSION_LISTpreg_quote(StringHelper::getCurrencyCode()));
        
$decimalSeparator preg_quote(StringHelper::getDecimalSeparator());

        return 
'~^(?:(?: *(?<PrefixedSign>[-+])? *(?<PrefixedCurrency>[' $currencyCodes ']) *(?<PrefixedSign2>[-+])? *(?<PrefixedValue>[0-9]+[' $decimalSeparator ']?[0-9*]*(?:E[-+]?[0-9]*)?) *)|(?: *(?<PostfixedSign>[-+])? *(?<PostfixedValue>[0-9]+' $decimalSeparator '?[0-9]*(?:E[-+]?[0-9]*)?) *(?<PostfixedCurrency>[' $currencyCodes ']) *))$~ui';
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0057 ]--