function apiCall($app, $key, $request) { global $aecConfig; if (empty($aecConfig->cfg['apiapplist'])) { header("HTTP/1.0 401 Unauthorized"); die; // die, die } if (isset($aecConfig->cfg['apiapplist'][$app])) { if (trim($key) == trim($aecConfig->cfg['apiapplist'][$app])) { if (empty($request)) { header("HTTP/1.0 400 Bad Request"); die; } if (get_magic_quotes_gpc()) { $request = stripslashes($request); } $req = json_decode($request); if (is_null($request)) { header("HTTP/1.0 415 Unsupported Media Type"); die; } if (!is_array($req)) { $req = array($req); } header("HTTP/1.0 200 OK"); $api = new aecAPI(); $return = array(); foreach ($req as $r) { $api->load($r); $r = new stdClass(); $r->response = new stdClass(); $r->error = null; if (empty($api->error)) { $api->resolve(); $r->response = $api->response; } else { $r->response->result = false; } $r->error = $api->error; $return[] = $r; } if (count($return) == 1) { $return = $return[0]; } echo json_encode($return); die; // regular die } } header("HTTP/1.0 401 Unauthorized"); die; // die, die }
/** * Replaces the matched tags. * * @param array An array of matches (see preg_match_all) * @return string */ protected function _replace(&$matches) { $permission = false; jimport('joomla.utilities.utility'); include_once JPATH_ROOT . "/components/com_acctexp/acctexp.class.php"; $user = JFactory::getUser(); $r = new stdClass(); $r->action = 'actionRestrictionCheck'; $r->user = new stdClass(); $r->user->userid = $user->id; $aecAPI = new aecAPI(); $aecAPI->load($r); if (empty($aecAPI->error)) { $api->resolve(); $permission = $api->response->result; } if ($permission) { return $matches[1]; } else { return ""; } }