Skip to content

Instantly share code, notes, and snippets.

@sn0opy
Last active August 31, 2020 18:17
Show Gist options
  • Save sn0opy/fce2bd21cc55cd4e431095a3d754760f to your computer and use it in GitHub Desktop.
Save sn0opy/fce2bd21cc55cd4e431095a3d754760f to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$f3 = Base::instance();
$f3->receivers = [
[
"url" => "http://rdmserver123:9001/raw",
"secret" => "pa55word"
],
[
"url" => "http://rdmserver456:9001/raw",
"secret" => "f00b4r!"
]
];
function forward_data($content) {
$f3 = Base::instance();
$contents = [];
foreach ($content as $cnt) {
if (!in_array($cnt->type, [2, 106, 102, 104, 101, 156])) {
continue;
}
array_push($contents, [
"data" => $cnt->payload,
"method" => $cnt->type,
"length" => strlen($cnt->payload)
]);
}
$data = [
"devicename" => "MADproxy",
"idfa" => "00000000-0000-0000-0000-00000000",
"trainerlvl" => 30,
"contents" => $contents,
"username" => $_SERVER['HTTP_ORIGIN']
];
foreach ($f3->receivers as $receiver) {
$options = [
'headers' => [
'User-Agent' => 'RDM proxy/1.0',
'Authorization' => 'Bearer '. $receiver["secret"]
]
];
$client = new Client($options);
$res = $client->post($receiver["url"], ['json' => $data, 'timeout' => 3]);
}
}
$f3->route('POST /', function() use($f3) {
$content = json_decode(file_get_contents('php://input'));
forward_data($content);
});
$f3->run();
@sn0opy
Copy link
Author

sn0opy commented Jan 28, 2020

Requires composer. Install dependencies via

composer require bcosca/fatfree-core guzzlehttp/guzzle

Save as index.php in your preferred location and point PD to http://server.com/location/. Do not point it directly to index.php nor use any other file names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment