Skip to content

Commit

Permalink
Dev Remote control fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Mar 29, 2013
1 parent 44118e9 commit 924db29
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
9 changes: 6 additions & 3 deletions application/controllers/admin/remotecontrol.php
Expand Up @@ -30,8 +30,7 @@ public function run()
{
$oHandler=new remotecontrol_handle($this->controller);
$RPCType=Yii::app()->getConfig("RPCInterface");

if (Yii::app()->getRequest()->isPostRequest) {
if (true || Yii::app()->getRequest()->isPostRequest) {
if ($RPCType=='xml')
{
$cur_path = get_include_path();
Expand All @@ -52,7 +51,10 @@ public function run()
elseif($RPCType=='json')
{
Yii::app()->loadLibrary('LSjsonRPCServer');

if (!isset($_SERVER['CONTENT_TYPE']))
{
$_SERVER['CONTENT_TYPE'] = explode(';', $_SERVER['HTTP_CONTENT_TYPE'])[0];
}
LSjsonRPCServer::handle($oHandler);
}
exit;
Expand Down Expand Up @@ -2346,6 +2348,7 @@ public function export_responses($sSessionKey, $iSurveyID, $sDocumentType, $sLan
$oFomattingOptions->headingFormat=$sHeadingType;
$oFomattingOptions->answerFormat=$sResponseType;
$oFomattingOptions->output='file';

$oExport=new ExportSurveyResultsService();
$sTempFile=$oExport->exportSurvey($iSurveyID,$sLanguageCode, $sDocumentType,$oFomattingOptions, '');
return new BigFile($sTempFile, true, 'base64');
Expand Down
3 changes: 2 additions & 1 deletion application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -524,8 +524,9 @@ function run($surveyid,$args) {
/* @var $blockData PluginEventContent */
$blocks[] = CHtml::tag('div', array('id' => $blockData->getCssId(), 'class' => $blockData->getCssClass()), $blockData->getContent());
}
$redata['completed'] = implode("\n", $blocks) ."\n". $redata['completed'];
}
$redata['completed'] = implode("\n", $blocks) ."\n". $redata['completed'];


echo templatereplace(file_get_contents($sTemplatePath."completed.pstpl"), array('completed' => $completed), $redata);
echo "\n";
Expand Down
17 changes: 8 additions & 9 deletions application/libraries/BigData.php
Expand Up @@ -17,7 +17,7 @@ class BigData {
* @param array $json
* @param int $options Same flags used in JSON_ENCODE.
*/
public static function json_echo($json, $options)
public static function json_echo($json, $options = 0)
{
// Scan array for any streams.
$hasStream = array_reduce($json, array('BigData', 'hasStream'), false);
Expand Down Expand Up @@ -132,13 +132,12 @@ protected static function json_echo_string($json)
echo json_encode($json);
}

protected static function json_echo_stream($json)
protected static function json_echo_stream(BigFile $data)
{
// Encode stream to base64.
echo "'";
stream_filter_append($json, 'convert.base64-encode', STREAM_FILTER_READ, array('line-length' => 50, 'line-break-chars' => "\n"));
fpassthru($json);
echo "'";
echo '"';
$data->render();
echo '"';
}


Expand Down Expand Up @@ -224,8 +223,8 @@ protected static function xmlrpc_echo_object($data)
protected static function xmlrpc_echo_stream($data)
{
echo '<base64>';
$data->
stream_filter_append($data, 'convert.base64-encode', STREAM_FILTER_READ, array('line-length' => 50, 'line-break-chars' => "\n"));
echo $data->fileName;
//stream_filter_append($data, 'convert.base64-encode', STREAM_FILTER_READ, array('line-length' => 50, 'line-break-chars' => "\n"));

echo '</base64>';
}
Expand All @@ -238,7 +237,7 @@ protected static function xmlrpc_echo_string($data)

class BigFile {

protected $fileName;
public $fileName;
protected $deleteAfterUse;
protected $defaultEcho;

Expand Down
11 changes: 5 additions & 6 deletions application/libraries/LSjsonRPCServer.php
@@ -1,5 +1,6 @@
<?php
<?php
Yii::import('application.libraries.BigData', true);
Yii::import('application.libraries.jsonRPCServer');
class LSjsonRPCServer extends jsonRPCServer
{
/**
Expand All @@ -9,8 +10,7 @@ class LSjsonRPCServer extends jsonRPCServer
* @return boolean
*/
public static function handle($object) {

// checks if a JSON-RCP request has been received
// checks if a JSON-RCP request has been received
if (
$_SERVER['REQUEST_METHOD'] != 'POST' ||
empty($_SERVER['CONTENT_TYPE']) ||
Expand All @@ -19,11 +19,10 @@ public static function handle($object) {
// This is not a JSON-RPC request
return false;
}

// reads the input data
$request = json_decode(file_get_contents('php://input'),true);

// executes the task on local object
// executes the task on local object
try {
if ($result = @call_user_func_array(array($object,$request['method']),$request['params'])) {
$response = array (
Expand Down

0 comments on commit 924db29

Please sign in to comment.