Skip to content

Instantly share code, notes, and snippets.

@svenberg
Forked from sn0opy/madrawproxy.php
Created July 7, 2020 18:03
Show Gist options
  • Save svenberg/3d747312c39939f2d0211422407cf268 to your computer and use it in GitHub Desktop.
Save svenberg/3d747312c39939f2d0211422407cf268 to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$f3 = Base::instance();
$f3->address = 'http://rdmserver:9001/raw';
$f3->authtoken = 'pa55word';
function forward_data($content) {
$f3 = Base::instance();
$options = [
'headers' => [
'User-Agent' => 'RDM proxy/1.0',
'Authorization' => 'Bearer '.$f3->authtoken
]
];
$client = new Client($options);
$contents = [];
foreach ($content as $cnt) {
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
];
$res = $client->post($f3->address, ['json' => $data]);
}
$f3->route('POST /', function() use($f3) {
$content = json_decode(file_get_contents('php://input'));
forward_data($content);
});
$f3->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment