OpenRA / openrauseraccounts

Connect phpBB forum accounts to OpenRA installations
https://forum.openra.net/ucp.php?i=232
GNU General Public License v2.0
3 stars 3 forks source link

Use a Symfony response object to output info data. #7

Closed ghost closed 6 years ago

ghost commented 6 years ago

Currently uses a dummy response while using echo to output data because the Symfony response will include header information. This information needs to be excluded to be compatible to game integration.

ghost commented 6 years ago

Another ugly approach that avoids the dummy response would be to assign the data to template vars and then include some php code in the template to do the formatting. Not recommended and probably even worse. https://wiki.phpbb.com/Tutorial.Template_syntax#PHP

pchote commented 6 years ago

The following works for me, and fixes the rendering in web browsers (because of the content type)

$yaml = "Player:\n";
$yaml .= "\tFingerprint: " . $data['fingerprint'] . "\n";
$yaml .=  "\tPublicKey: " . base64_encode($data['public_key']) . "\n";
$yaml .=  "\tKeyRevoked: " . ($data['revoked'] ? 'true' : 'false') . "\n";
$yaml .=  "\tProfileID: " . $data['user_id'] . "\n";
$yaml .=  "\tProfileName: " . $data['username'] . "\n";
$yaml .=  "\tProfileRank: Registered User\n";
$yaml .=  "\tBadges:\n";
if ($badges)
{
    $i = 0;
    foreach ($badges as $badge)
    {
        $yaml .=  "\t\tBadge@$i:\n";
        $yaml .=  "\t\t\tLabel: " . $badge['badge_label'] . "\n";
        $yaml .=  "\t\t\tIcon16: " . generate_board_url () . '/' . $this->config['badges_path'] . '/' . $badge['badge_icon_16'] . "\n";
        $i++;
    }
}

$response = new Response($yaml);
$response->headers->set('Content-Type', 'Content-type: text/plain; charset=utf-8');
return $response;
ghost commented 6 years ago

Works as promised so closing.