Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openml_OS/controllers/Api_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function index() {
$this->_show_webpage();
}

public function v1($type) {
public function v1(...$args) {
$this->bootstrap('1');
}

Expand Down
22 changes: 21 additions & 1 deletion openml_OS/controllers/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function __construct() {
}
}

public function v1($type) {
public function v1(...$args) {
$this->load->Model('data/v1/Data_server');
$this->bootstrap('1');
}
Expand All @@ -54,6 +54,26 @@ private function bootstrap($version) {
$controller = array_shift($segs);
$this->version = array_shift($segs);
$function = array_shift($segs);

$function_whitelist = array('download', 'view', 'get_csv');

if (!in_array($function, $function_whitelist)) {
http_response_code(404);
echo 'Function not valid.';
return;
}

if (!$segs) {
http_response_code(400);
echo 'Missing value for argument id.';
return;
}

if (count($segs) > 2) {
http_response_code(400);
echo 'Expected at most two arguments: id (required) and name (optional).';
return;
}

call_user_func_array(array($this->Data_server, $function), $segs);
}
Expand Down