private static function generateNonSandboxedCode(&$params) { //Get the rendered HTML code for the app $server = new RingsideSocialServerRender(); $responseHTML = $server->execute($params); //Need to clean up the code so we can document.wrte it out //No line breaks, escape \, and break up script tags $bad = array("\n", "\"", "<script", "</script>"); $good = array("", "\\\"", "<sc\" + \"ript", "</sc\" + \"ript>"); $newphrase = str_replace($bad, $good, $responseHTML); //Generate the JavaScript that will write the HTML out onto the page //We are in script tags alread so no need for them here $scriptOut = 'document.write( "' . $newphrase . '" );'; return $scriptOut; }
require_once "LocalSettings.php"; require_once "ringside/social/RingsideSocialServerRender.php"; require_once 'ringside/api/Session.php'; $override_from_query_string = array('social_session_key'); // TODO: This requires the API and Social tiers to be co-located (or to have a shared session repository) session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc')); session_cache_limiter('none'); $server = new RingsideSocialServerRender(); if (isset($_REQUEST['format']) && $_REQUEST['format'] == 'JSON') { // The widget requires JSON for cross domain support $json_response = null; $responseHTML = ''; try { error_log("fbml render request=" . $_REQUEST['fbml']); $fbmlReq = $_REQUEST['fbml']; $responseHTML = $server->execute($_REQUEST); } catch (Exception $e) { $json_response = json_encode(array('response' => 'error', 'widgetid' => $_REQUEST['widgetid'], 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine())); error_log($e->getTraceAsString()); } if (is_null($json_response)) { if (array_key_exists('widgetid', $_REQUEST)) { $response['widgetid'] = $_REQUEST['widgetid']; } $response['response'] = "success"; if ($_REQUEST['method'] == 'app') { $decodedResponse = json_decode($responseHTML, true); if (!isset($decodedResponse) || strlen($decodedResponse) == 0) { $response['content'] = $responseHTML; } else { $response['content'] = $decodedResponse;