summaryrefslogtreecommitdiffstats
path: root/application/core
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-08-14 17:06:07 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-09-02 22:02:27 +0200
commit84ce2c6ce0eb1b4f2f32c4ae0d7e08f3571f5018 (patch)
tree895a059bdc6d82a462a055764e761cdd16656a63 /application/core
parentf8417cd3aa92f49cbe98188cd6fca2ec50da9613 (diff)
Provide json output for api functions
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/core')
-rw-r--r--application/core/MY_Controller.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php
index 278768ad2..3ee63424a 100644
--- a/application/core/MY_Controller.php
+++ b/application/core/MY_Controller.php
@@ -11,7 +11,7 @@ class MY_Controller extends CI_Controller {
public $data = array();
public $var;
- private $json_enabled_functions = array(
+ protected $json_enabled_functions = array(
);
function __construct()
@@ -31,6 +31,16 @@ class MY_Controller extends CI_Controller {
mb_internal_encoding('UTF-8');
$this->load->helper(array('form', 'filebin'));
+ if (isset($_SERVER["HTTP_ACCEPT"])) {
+ if ($_SERVER["HTTP_ACCEPT"] == "application/json") {
+ request_type("json");
+ }
+ }
+
+ if (request_type() == "json" && ! in_array($this->uri->rsegment(2), $this->json_enabled_functions)) {
+ show_error("Function not JSON enabled");
+ }
+
$this->data['title'] = "FileBin";
}
}