/** * Approve initial CORS request. */ private function _checkCORS() { // Access-Control headers are received during OPTIONS requests if (strcasecmp($_SERVER['REQUEST_METHOD'], "OPTIONS") === 0) { Response::result('CORS OK :-)'); } }
}, 'Logged on users role: Basic, OrgAdmin (if member of Dataporten group RelayAdmin) or SuperAdmin (Scope: user).')]); } // DEV ROUTES FOR TESTING (Superadmin access only) if ($dataporten->hasOauthScopeAdmin() && $dataporten->isSuperAdmin()) { $router->addRoutes([array('GET', '/dev/table/[a:tableName]/schema/', function ($table_name) { global $relay; Response::result(array('status' => true, 'data' => $relay->sql()->getTableSchema($table_name))); }, 'Table schema.'), array('GET', '/dev/table/[a:tableName]/dump/', function ($table_name) { global $relay; Response::result(array('status' => true, 'data' => $relay->sql()->getTableDump($table_name, 50))); }, 'Table dump. Top 50.'), array('GET', '/dev/table/[a:tableName]/dump/top/[i:top]', function ($table_name, $top) { global $relay; Response::result(array('status' => true, 'data' => $relay->sql()->getTableDump($table_name, $top))); }, 'Table dump. Top $top.'), array('GET', '/dev/memorytest/', function () { $test = new MongoTest(); Response::result(array('status' => true, 'data' => $test->memoryTest())); }, 'Test mongodb/php memory consumption.')]); } // ---------------------- MATCH AND EXECUTE REQUESTED ROUTE ---------------------- $match = $router->match(); if ($match && is_callable($match['target'])) { sanitizeInput(); call_user_func_array($match['target'], $match['params']); } else { Response::error(404, "The requested resource route could not be found."); } // ---------------------- /.MATCH AND EXECUTE REQUESTED ROUTE ---------------------- // -------------------- UTILS -------------------- // /** * http://stackoverflow.com/questions/4861053/php-sanitize-values-of-a-array/4861211#4861211 */