!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)

/usr/share/php/tests/mongodb/scripts/   drwxr-xr-x
Free 12.98 GB of 57.97 GB (22.39%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

declare(strict_types=1);

set_error_handler(function($errno$errstr$errfile$errline) {
    
fprintf(STDERR"%s\n"$errstr);
    exit(
1);
});

set_exception_handler(function($e) {
    
fprintf(STDERR"%s: %s\n"get_class($e), $e->getMessage());
    exit(
1);
});

function 
getId(string $config): string {
    
$config json_decode($confignull512JSON_THROW_ON_ERROR);

    if (!isset(
$config->id) || !is_string($config->id)) {
        throw new 
UnexpectedValueException('Could not determine id');
    }

    return 
$config->id;
}

function 
getTopology(string $file): string {
    
$topology basename(dirname($file));

    if (!
in_array($topology, ['servers''replica_sets''sharded_clusters'])) {
        throw new 
UnexpectedValueException('Unsupported topology: ' $topology);
    }

    return 
$topology;
}

function 
request(string $uri, array $options = []): stdClass {
    
$options += [
        
'method' => 'GET',
        
'header' => 'Accept: application/json',
        
'ignore_errors' => true,
    ];
    
$response file_get_contents($urifalsestream_context_create(['http' => $options]));

    if (
preg_match('#HTTP/1.[01] ([0-9]+)#'$http_response_header[0], $matches) !== 1) {
        throw new 
UnexpectedValueException('Could not determine HTTP response code');
    }

    
$code = (int) $matches[1];

    if (
$code !== 200) {
        throw new 
UnexpectedValueException(sprintf("%s %s returned HTTP response code: %d\n\n%s"$options['method'] ?? 'GET'$uri$code$response));
    }

    return 
json_decode($responsenull512JSON_THROW_ON_ERROR);
}

function 
start(string $uristring $config): void {
    
$options = [
        
'method' => 'POST',
        
'header' => "Accept: application/json\r\n" .
                    
"Content-type: application/x-www-form-urlencoded",
        
'content' => $config,
        
'timeout' => 120,
    ];

    
printf("%s\n"json_encode(request($uri$options), JSON_PRETTY_PRINT));
}

function 
status(string $uri): void {
    
printf("%s\n"json_encode(request($uri), JSON_PRETTY_PRINT));
}

function 
stop(string $uri): void {
    
$options = [
        
'method' => 'DELETE',
        
'header' => "Accept: application/json\r\n" .
                    
"Content-type: application/x-www-form-urlencoded",
        
'content' => $config,
        
'timeout' => 120,
    ];

    
printf("%s\n"json_encode(request($uri$options), JSON_PRETTY_PRINT));
}

function 
usage(): void {
    global 
$argv;

    
fprintf(STDERR"usage: %s <action> <id>|<path/to/config.json>\n"$argv[0]);
    
fprintf(STDERR"action: start|status|stop\n");
    exit(
1);
}

$tools getenv('DRIVER_TOOLS') ?: '/home/jmikola/workspace/mongodb/drivers-evergreen-tools';
$server getenv('MONGO_ORCHESTRATION_URI') ?: 'http://localhost:8889';

if (
$argc 2) {
    
usage();
}

$action $argv[1] ?? null;

switch (
$action) {
    case 
'start':
        
$file $argv[2];

        if (!
is_readable($file)) {
            throw new 
UnexpectedValueException('Cannot read input file');
        }

        
$topology getTopology($file);

        
$config file_get_contents($file);
        
$config str_replace('ABSOLUTE_PATH_REPLACEMENT_TOKEN'$tools$config);
        
start(sprintf('%s/v1/%s'$server$topology), $config);
        break;

    case 
'status':
        
$topology $argv[2];
        
$id $argv[3];
        
status(sprintf('%s/v1/%s/%s'$server$topology$id));
        break;

    case 
'stop':
        
$topology $argv[2];
        
$id $argv[3];
        
stop(sprintf('%s/v1/%s/%s'$server$topology$id));
        break;

    case 
'list':
        foreach ([
'servers''replica_sets''sharded_clusters'] as $topology) {
            
$response request(sprintf('%s/v1/%s'$server$topology));
            
printf("%s:\n"$topology);
            
printf("%s\n\n"json_encode($response->$topologyJSON_PRETTY_PRINT));
        }
        break;

    default:
        
usage();
}

:: 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.0058 ]--