<?php

/*
 * Copyright (c) 2018 Earworks.
 * Codeigniter Project Template Modification
 * Please contact our email for more information :
 *  contact@earworks.co.id
 */
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Description of Base_Input
 *
 * @author Fajar Dwi Rianto <fajar@earworks.co.id>
 * @since 1.0
 */
class Base_Input extends CI_Input {

    function post($index = NULL, $xss_clean = FALSE, $default_value = NULL, $strip_html = true) {
        // Check if a field has been provided
        if ($index === NULL AND ! empty($_POST)) {
            $post = array();

            // Loop through the full _POST array and return it
            foreach (array_keys($_POST) as $key) {
                $post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean);
            }

            return $post;
        }

        $ret_val = $this->_fetch_from_array($_POST, $index, $xss_clean);
        if (!$ret_val)
            $ret_val = $default_value;

        return ($strip_html) ? $this ->strip_html($ret_val) : $ret_val;
    }
    private function strip_html($str)
    {
        return htmlspecialchars(htmlentities(strip_tags($str)));
    }

}
