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

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/qr.picotech.app/public_html_v3_3/backup/vendor/brick/math/   drwxr-xr-x
Free 23.7 GB of 117.98 GB (20.09%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

/**
 * This script stress tests calculators with random large numbers and ensures that all implementations return the same
 * results. It is designed to run in an infinite loop unless a bug is found.
 */

declare(strict_types=1);

require 
__DIR__ '/vendor/autoload.php';

use 
Brick\Math\Internal\Calculator;

(new class(
30) { // max digits
    
private $gmp;
    private 
$bcmath;
    private 
$native;

    private 
$maxDigits;

    public function 
__construct(int $maxDigits)
    {
        
$this->gmp    = new Calculator\GmpCalculator();
        
$this->bcmath = new Calculator\BcMathCalculator();
        
$this->native = new Calculator\NativeCalculator();

        
$this->maxDigits $maxDigits;
    }

    public function 
__invoke() : void
    
{
        for (;;) {
            
$a $this->generateRandomNumber();
            
$b $this->generateRandomNumber();
            
$c $this->generateRandomNumber();

            
$this->runTests($a$b);
            
$this->runTests($b$a);

            if (
$a !== '0') {
                
$this->runTests("-$a"$b);
                
$this->runTests($b"-$a");
            }

            if (
$b !== '0') {
                
$this->runTests($a"-$b");
                
$this->runTests("-$b"$a);
            }

            if (
$a !== '0' && $b !== '0') {
                
$this->runTests("-$a""-$b");
                
$this->runTests("-$b""-$a");
            }

            if (
$c !== '0') {
                
$this->test("$a POW $b MOD $c", function(Calculator $calc) use($a$b$c) {
                    return 
$calc->modPow($a$b$c);
                });
            }
        }
    }

    
/**
     * @param string $a The left operand.
     * @param string $b The right operand.
     */
    
private function runTests(string $astring $b) : void
    
{
        
$this->test("$a + $b", function(Calculator $c) use($a$b) {
            return 
$c->add($a$b);
        });

        
$this->test("$a - $b", function(Calculator $c) use($a$b) {
            return 
$c->sub($a$b);
        });

        
$this->test("$a * $b", function(Calculator $c) use($a$b) {
            return 
$c->mul($a$b);
        });

        if (
$b !== '0') {
            
$this->test("$a / $b", function(Calculator $c) use($a$b) {
                return 
$c->divQR($a$b);
            });

            
$this->test("$a MOD $b", function(Calculator $c) use($a$b) {
                return 
$c->mod($a$b);
            });
        }

        if (
$b !== '0' && $b[0] !== '-') {
            
$this->test("INV $a MOD $b", function(Calculator $c) use($a$b) {
                return 
$c->modInverse($a$b);
            });
        }

        
$this->test("GCD $a$b", function(Calculator $c) use($a$b) {
            return 
$c->gcd($a$b);
        });

        if (
$a[0] !== '-') {
            
$this->test("SQRT $a", function(Calculator $c) use($a$b) {
                return 
$c->sqrt($a);
            });
        }

        
$this->test("$a AND $b", function(Calculator $c) use($a$b) {
            return 
$c->and($a$b);
        });

        
$this->test("$a OR $b", function(Calculator $c) use($a$b) {
            return 
$c->or($a$b);
        });

        
$this->test("$a XOR $b", function(Calculator $c) use($a$b) {
            return 
$c->xor($a$b);
        });
    }

    
/**
     * @param string  $test     A string representing the test being executed.
     * @param Closure $callback A callback function accepting a Calculator instance and returning a calculation result.
     */
    
private function test(string $testClosure $callback) : void
    
{
        static 
$testCounter 0;
        static 
$lastOutputTime 0.0;
        static 
$currentSecond 0;
        static 
$currentSecondTestCounter 0;
        static 
$testsPerSecond 0;

        
$gmpResult    $callback($this->gmp);
        
$bcmathResult $callback($this->bcmath);
        
$nativeResult $callback($this->native);

        if (
$gmpResult !== $bcmathResult) {
            
self::failure('GMP''BCMath'$test);
        }

        if (
$gmpResult !== $nativeResult) {
            
self::failure('GMP''Native'$test);
        }

        
$testCounter++;
        
$currentSecondTestCounter++;

        
$time microtime(true);
        
$second = (int) $time;

        if (
$second !== $currentSecond) {
            
$currentSecond $second;
            
$testsPerSecond $currentSecondTestCounter;
            
$currentSecondTestCounter 0;
        }

        if (
$time $lastOutputTime >= 0.1) {
            echo 
"\r"number_format($testCounter), ' ('number_format($testsPerSecond) . ' / s)';
            
$lastOutputTime $time;
        }
    }

    
/**
     * @param string $c1   The name of the first calculator.
     * @param string $c2   The name of the second calculator.
     * @param string $test A string representing the test being executed.
     */
    
private static function failure(string $c1string $c2string $test) : void
    
{
        echo 
PHP_EOL;
        echo 
'FAILURE!'PHP_EOL;
        echo 
$c1' vs '$c2PHP_EOL;
        echo 
$testPHP_EOL;
        die;
    }

    private function 
generateRandomNumber() : string
    
{
        
$length random_int(1$this->maxDigits);

        
$number '';

        for (
$i 0$i $length$i++) {
            
$number .= random_int(09);
        }

        
$number ltrim($number'0');

        if (
$number === '') {
            return 
'0';
        }

        return 
$number;
    }
})();

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

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

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