You are here

function drd_server_output in Drupal Remote Dashboard Server 6.2

Same name and namespace in other branches
  1. 7.2 drd_server.module \drd_server_output()

Prepare the output to be sent back to the DRD dashboard. This preparation json encodes the output and then encrypts the resulting string if encryption is available.

Parameters

string $output:

bool $encrypt:

Return value

string

2 calls to drd_server_output()
drd_server_error in ./drd_server.module
Prepare an error message for returning to the XMLRPC caller.
drd_server_result in ./drd_server.module
Prepare the result for returning it to the XMLRPC caller.

File

./drd_server.module, line 798

Code

function drd_server_output($output, $encrypt = TRUE) {
  if (!empty($output)) {

    // json_encode() does not escape <, > and &, so we do it with str_replace().
    $output = str_replace(array(
      '<',
      '>',
      '&',
    ), array(
      '\\u003c',
      '\\u003e',
      '\\u0026',
    ), json_encode($output));
    if ($encrypt) {
      $aes = drd_server_aes();
      if (!empty($aes)) {
        $output = drd_server_aes_encrypt($output, TRUE, $aes['key'], $aes['cipher'], _drd_server_iv(), $aes['impl']);
      }
    }
  }
  return $output;
}