mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-22 20:45:45 +08:00
29 lines
825 B
PHP
Executable file
29 lines
825 B
PHP
Executable file
<?php
|
|
|
|
// Replaces dashes in keys with underscores
|
|
foreach($args as $index => $arg) {
|
|
$split = strpos($arg, "=");
|
|
if ( $split ) {
|
|
$key = str_replace('-', '_', substr( $arg , 0, $split ) );
|
|
$value = substr( $arg , $split, strlen( $arg ) );
|
|
|
|
// Removes unnecessary bash quotes
|
|
$value = trim( $value,'"' ); // Remove last quote
|
|
$value = str_replace( '="', '=', $value ); // Remove quote right after equals
|
|
|
|
$args[$index] = $key.$value;
|
|
} else {
|
|
$args[$index] = str_replace('-', '_', $arg);
|
|
}
|
|
|
|
}
|
|
|
|
// Converts --arguments into $arguments
|
|
parse_str( implode( '&', $args ) );
|
|
|
|
$curl = curl_init( "$captaincore_gui/wp-json/captaincore/v1/client" );
|
|
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
|
|
$response = curl_exec( $curl );
|
|
$response = json_decode( $response, true );
|
|
|
|
echo trim( $response[ $field ] );
|