diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index 59628f4..93d68e0 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -204,6 +204,7 @@ class Main extends CI_Controller function index() { + $this->load->helper('json'); if (!$this->input->post('submit')) { @@ -369,6 +370,7 @@ class Main extends CI_Controller function view() { + $this->load->helper('json'); $this->load->model('pastes'); $check = $this->pastes->checkPaste(2); diff --git a/htdocs/application/helpers/json_helper.php b/htdocs/application/helpers/json_helper.php new file mode 100755 index 0000000..8fe3c02 --- /dev/null +++ b/htdocs/application/helpers/json_helper.php @@ -0,0 +1,58 @@ + $value) + { + $output_indexed[] = json_encode($value); + $output_associative[] = json_encode($key) . ':' . json_encode($value); + + if ($output_index_count !== NULL && $output_index_count++ !== $key) + { + $output_index_count = NULL; + } + } + + if ($output_index_count !== NULL) + { + return '[' . implode(',', $output_indexed) . ']'; + } + else + { + return '{' . implode(',', $output_associative) . '}'; + } + default: + return ''; // Not supported + + + } + } +}