function doRpc($cdata) { global $API; try { if (!isset($API[$cdata->action])) { throw new Exception('Call to undefined action: ' . $cdata->action); } $action = $cdata->action; $a = $API[$action]; doAroundCalls($a['before'], $cdata); $method = $cdata->method; $mdef = $a['methods'][$method]; if (!$mdef) { throw new Exception("Call to undefined method: {$method} on action {$action}"); } doAroundCalls($mdef['before'], $cdata); $r = array('type' => 'rpc', 'tid' => $cdata->tid, 'action' => $action, 'method' => $method); require_once "classes/{$action}.php"; $o = new $action(); $params = isset($cdata->data) && is_array($cdata->data) ? $cdata->data : array(); $r['result'] = call_user_func_array(array($o, $method), $params); doAroundCalls($mdef['after'], $cdata, $r); doAroundCalls($a['after'], $cdata, $r); } catch (Exception $e) { $r['type'] = 'exception'; $r['message'] = $e->getMessage(); $r['where'] = $e->getTraceAsString(); } return $r; }
function doRpc($cdata) { global $API; global $appAccess; try { if (!$appAccess) { throw new Exception('Access Denied: Please make sure API Key is typed correctly in the settings tab'); } if (!isset($API[$cdata->action])) { throw new Exception('Call to undefined action: ' . $cdata->action); } $action = $cdata->action; $a = $API[$action]; doAroundCalls($a['before'], $cdata); $method = $cdata->method; $mdef = $a['methods'][$method]; if (!$mdef) { throw new Exception("Call to undefined method: {$method} on action {$action}"); } doAroundCalls($mdef['before'], $cdata); $r = array('type' => 'rpc', 'tid' => $cdata->tid, 'action' => $action, 'method' => $method); if (isset($cdata->module)) { require_once "../modules/{$cdata->module}/dataProvider/{$action}.php"; } else { require_once "../dataProvider/{$action}.php"; } $o = new $action(); if (isset($mdef['len'])) { $params = isset($cdata->data) && is_array($cdata->data) ? $cdata->data : array(); } else { $params = array($cdata->data); } $r['result'] = call_user_func_array(array($o, $method), $params); doAroundCalls($mdef['after'], $cdata, $r); doAroundCalls($a['after'], $cdata, $r); } catch (Exception $e) { $r['success'] = false; $r['type'] = 'exception'; $r['message'] = $e->getMessage(); $r['where'] = $e->getTraceAsString(); } // $_SESSION['server']['last_tid'] = $cdata->tid; return $r; }
function doRpc($cdata) { global $API; try { /** * Check if user is authorized/Logged in */ // if(isset($_SESSION['user']['auth'])){ // if ($_SESSION['user']['auth'] != true){ // throw new Exception('Authorization Required.'); // } // }else{ // throw new Exception('Authorization Required.'); // } // /** // * Check if tdi is a valid tid (expected tid) // */ // if($_SESSION['server']['last_tid'] != null){ // $expectedTid = $_SESSION['server']['last_tid'] + 1; // if($cdata->tid != $expectedTid){ // throw new Exception('Call to unrecognize transaction ID: // GaiaEHR does not recognized this transaction ID.'); // } // } if (!isset($API[$cdata->action])) { throw new Exception('Call to undefined action: ' . $cdata->action); } $action = $cdata->action; $a = $API[$action]; doAroundCalls($a['before'], $cdata); $method = $cdata->method; $mdef = $a['methods'][$method]; if (!$mdef) { throw new Exception("Call to undefined method: {$method} on action {$action}"); } doAroundCalls($mdef['before'], $cdata); $r = array('type' => 'rpc', 'tid' => $cdata->tid, 'action' => $action, 'method' => $method); if (isset($cdata->module)) { require_once "../modules/{$cdata->module}/dataProvider/{$action}.php"; } else { require_once "../dataProvider/{$action}.php"; } $o = new $action(); if (isset($mdef['len'])) { $params = isset($cdata->data) && is_array($cdata->data) ? $cdata->data : array(); } else { $params = array($cdata->data); } $r['result'] = call_user_func_array(array($o, $method), $params); doAroundCalls($mdef['after'], $cdata, $r); doAroundCalls($a['after'], $cdata, $r); } catch (Exception $e) { $r['type'] = 'exception'; $r['message'] = $e->getMessage(); $r['where'] = $e->getTraceAsString(); } // $_SESSION['server']['last_tid'] = $cdata->tid; return $r; }