Files
php_task_1/application/core/Manaknight_Input.php
T

35 lines
992 B
PHP
Raw Normal View History

2022-06-30 05:46:02 -04:00
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
/**
* Input
* @copyright 2019 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*/
class Manaknight_Input extends CI_Input
{
function __construct()
{
parent::__construct();
$content_type = $this->get_request_header('Content-Type');
if ($this->method('post') && stripos($content_type, 'application/json') !== FALSE &&
($postdata = $this->raw_post()) &&
in_array($postdata[0], array('{', '[')))
{
$decoded_postdata = json_decode($postdata, true);
if ((json_last_error() == JSON_ERROR_NONE))
{
$_POST = $decoded_postdata;
}
}
}
protected function raw_post()
{
return file_get_contents('php://input');
}
}