Example #1
0
 public static function init()
 {
     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
     $dataPass = "";
     $mxAjaxRequest = "";
     $htmlresponse = false;
     if (isset($_GET["json"])) {
         if ($_SERVER["REQUEST_METHOD"] === "GET") {
             $dataPass = $_GET;
         } else {
             $dataPass = $_POST;
         }
         $mxAjaxRequest = $json->decode($dataPass["mxAjaxParam"]);
     } else {
         $mxAjaxRequest = mxAjax::convertToJsonRequest();
     }
     $mxAjaxResponse = "";
     if (isset($mxAjaxRequest["calls"])) {
         //multiple function call
         $mxAjaxResponse = array();
         foreach ($mxAjaxRequest["calls"] as $key => $call) {
             foreach ($call as $_key => $_value) {
                 $functionName = $_key;
                 $functionCall = "\$functionReturnData = " . $functionName . "(";
                 $innCtr = 0;
                 foreach ($_value as $__key => $__value) {
                     if ($__key != 'htmlresponse') {
                         $innCtr++;
                         if ($innCtr > 1) {
                             $functionCall .= ",";
                         }
                         if (is_string($__value)) {
                             $functionCall .= "'" . $__value . "'";
                         } else {
                             $functionCall .= $__value;
                         }
                     }
                 }
                 $functionCall = $functionCall . ");";
                 eval($functionCall);
                 $callResponse = array();
                 $callResponse["functionName"] = $functionName;
                 $callResponse["data"] = $functionReturnData;
                 $mxAjaxResponse["calls"][] = $callResponse;
             }
         }
     } else {
         //single function call
         $functionCall = "";
         foreach ($mxAjaxRequest as $_key => $_value) {
             $functionName = $_key;
             if (strtolower($functionName) !== "htmlresponse") {
                 $functionCall = "\$functionReturnData = " . $functionName . "(";
                 $params = array_keys($_value);
                 $innCtr = 0;
                 for ($ctr = 0; $ctr < count($params); $ctr++) {
                     if (strtolower($params[$ctr]) != 'htmlresponse') {
                         $innCtr++;
                         if ($innCtr > 1) {
                             $functionCall .= ",";
                         }
                         $__value = $_value[$params[$ctr]];
                         if (is_string($__value)) {
                             $functionCall .= "'" . $__value . "'";
                         } else {
                             $functionCall .= $__value;
                         }
                     }
                 }
                 $functionCall = $functionCall . ");";
             } else {
                 $htmlresponse = $_value;
             }
         }
         eval($functionCall);
         $mxAjaxResponse = $functionReturnData;
     }
     if (!$htmlresponse) {
         $mxAjaxResponse = $json->encode($mxAjaxResponse);
     }
     echo trim($mxAjaxResponse);
     exit;
 }
Example #2
0
\t\t\t\t<h1>Dynamic Content</h1>
\t\t\t\t<b>All of this content is comming from Server side CF Page</b>
\t\t\t\t<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse
\t\t\t\t  vulputate felis ut est. Vivamus congue. Nullam consequat. Etiam elit
\t\t\t\t  ipsum, pulvinar in, commodo sed, malesuada et, wisi. Maecenas nunc odio,
\t\t\t\t  interdum et, mollis eget, egestas quis, enim. Vestibulum augue leo,
\t\t\t\t</p>
\t\t\t</body>
\t\t\t</html>
\t\t\t<br><br><br> {$date};
END;
    $retData = ob_get_contents();
    ob_end_clean();
    return $retData;
}
function setRating($rating)
{
    return true;
}
function getMessageTickerData()
{
    $db = new ExampleDbConnection();
    $rs = $db->getAllQuote();
    $retData = array();
    foreach ($rs as $row) {
        $retData[] = $row["quote"];
    }
    return $retData;
}
mxAjax::init();