diff options
Diffstat (limited to 'application/controllers/api')
-rw-r--r-- | application/controllers/api/v1/api_info.php | 16 | ||||
-rw-r--r-- | application/controllers/api/v1/file.php | 91 | ||||
-rw-r--r-- | application/controllers/api/v1/user.php | 75 |
3 files changed, 0 insertions, 182 deletions
diff --git a/application/controllers/api/v1/api_info.php b/application/controllers/api/v1/api_info.php deleted file mode 100644 index cd94869f8..000000000 --- a/application/controllers/api/v1/api_info.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/* - * Copyright 2014 Florian "Bluewind" Pritz <bluewind@server-speed.net> - * - * Licensed under AGPLv3 - * (see COPYING for full license text) - * - */ -namespace controllers\api\v1; - -class api_info extends \controllers\api\api_controller { - static public function get_version() - { - return "1.4.0"; - } -} diff --git a/application/controllers/api/v1/file.php b/application/controllers/api/v1/file.php deleted file mode 100644 index 6536335cb..000000000 --- a/application/controllers/api/v1/file.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php -/* - * Copyright 2014 Florian "Bluewind" Pritz <bluewind@server-speed.net> - * - * Licensed under AGPLv3 - * (see COPYING for full license text) - * - */ -namespace controllers\api\v1; - -class file extends \controllers\api\api_controller { - public function __construct() - { - parent::__construct(); - - $this->load->model('mfile'); - $this->load->model('mmultipaste'); - } - - public function upload() - { - $this->muser->require_access("basic"); - - $files = getNormalizedFILES(); - - if (empty($files)) { - throw new \exceptions\PublicApiException("file/no-file", "No file was uploaded or unknown error occurred."); - } - - \service\files::verify_uploaded_files($files); - - $limits = $this->muser->get_upload_id_limits(); - $userid = $this->muser->get_userid(); - $urls = array(); - - foreach ($files as $file) { - $id = $this->mfile->new_id($limits[0], $limits[1]); - \service\files::add_uploaded_file($userid, $id, $file["tmp_name"], $file["name"]); - $ids[] = $id; - $urls[] = site_url($id).'/'; - } - - return array( - "ids" => $ids, - "urls" => $urls, - ); - } - - public function get_config() - { - return array( - "upload_max_size" => $this->config->item("upload_max_size"), - "max_files_per_request" => intval(ini_get("max_file_uploads")), - "max_input_vars" => intval(ini_get("max_input_vars")), - "request_max_size" => return_bytes(ini_get("post_max_size")), - ); - } - - public function history() - { - $this->muser->require_access("apikey"); - $history = \service\files::history($this->muser->get_userid()); - foreach ($history['items'] as $key => $item) { - unset($history['items'][$key]['thumbnail']); - } - foreach ($history['multipaste_items'] as $key => $multipaste_item) { - foreach ($multipaste_item['items'] as $inner_key => $item) { - unset($history['multipaste_items'][$key]['items'][$inner_key]['sort_order']); - } - } - return $history; - } - - public function delete() - { - $this->muser->require_access("apikey"); - $ids = $this->input->post("ids"); - return \service\files::delete($ids); - } - - public function create_multipaste() - { - $this->muser->require_access("basic"); - $ids = $this->input->post("ids"); - $userid = $this->muser->get_userid(); - $limits = $this->muser->get_upload_id_limits(); - - return \service\files::create_multipaste($ids, $userid, $limits); - } -} -# vim: set noet: diff --git a/application/controllers/api/v1/user.php b/application/controllers/api/v1/user.php deleted file mode 100644 index 38247d02c..000000000 --- a/application/controllers/api/v1/user.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/* - * Copyright 2014 Florian "Bluewind" Pritz <bluewind@server-speed.net> - * - * Licensed under AGPLv3 - * (see COPYING for full license text) - * - */ -namespace controllers\api\v1; - -class user extends \controllers\api\api_controller { - public function __construct() - { - parent::__construct(); - - $this->load->model('muser'); - } - - public function apikeys() - { - $this->muser->require_access("full"); - return \service\user::apikeys($this->muser->get_userid()); - } - - public function create_apikey() - { - $username = $this->input->post("username"); - $password = $this->input->post("password"); - if ($username && $password) { - if (!$this->muser->login($username, $password)) { - throw new \exceptions\NotAuthenticatedException("user/login-failed", "Login failed"); - } - } - - $this->muser->require_access("full"); - - $userid = $this->muser->get_userid(); - $comment = $this->input->post("comment"); - $comment = $comment === false ? "" : $comment; - $access_level = $this->input->post("access_level"); - - $key = \service\user::create_apikey($userid, $comment, $access_level); - - return array( - "new_key" => $key, - ); - } - - public function delete_apikey() - { - $this->muser->require_access("full"); - - $userid = $this->muser->get_userid(); - $key = $this->input->post("delete_key"); - - $this->db->where('user', $userid) - ->where('key', $key) - ->delete('apikeys'); - - $affected = $this->db->affected_rows(); - - assert($affected >= 0 && $affected <= 1); - if ($affected == 1) { - return array( - "deleted_keys" => array( - $key => array ( - "key" => $key, - ), - ), - ); - } else { - throw new \exceptions\PublicApiException('user/delete_apikey/failed', 'Apikey deletion failed. Possibly wrong owner.'); - } - } -} |