#1025 json request 호환 문제 수정

deprecated 이므로 내장함수 exec_json 사용 권장!
This commit is contained in:
conory 2018-04-06 12:09:01 +09:00
parent eb17819ce0
commit 07dc7a2311

View file

@ -1144,13 +1144,20 @@ class Context
$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input"); $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
} }
// Pretend that this request is XMLRPC for compatibility with XE third-party.
if(isset($_POST['_rx_ajax_compat']) && $_POST['_rx_ajax_compat'] === 'XMLRPC')
{
self::$_instance->request_method = 'XMLRPC';
return;
}
// Check JSON // Check JSON
foreach(array($_SERVER['HTTP_ACCEPT'], $_SERVER['HTTP_CONTENT_TYPE'], $_SERVER['CONTENT_TYPE']) as $header) foreach(array($_SERVER['HTTP_ACCEPT'], $_SERVER['HTTP_CONTENT_TYPE'], $_SERVER['CONTENT_TYPE']) as $header)
{ {
if(strpos($header, 'json') !== false) if(strpos($header, 'json') !== false)
{ {
self::$_instance->request_method = 'JSON'; self::$_instance->request_method = 'JSON';
break; return;
} }
} }
@ -1158,11 +1165,7 @@ class Context
if(!$_POST && !empty($GLOBALS['HTTP_RAW_POST_DATA'])) if(!$_POST && !empty($GLOBALS['HTTP_RAW_POST_DATA']))
{ {
self::$_instance->request_method = 'XMLRPC'; self::$_instance->request_method = 'XMLRPC';
} return;
// Pretend that this request is XMLRPC for compatibility with XE third-party.
elseif (isset($_POST['_rx_ajax_compat']) && $_POST['_rx_ajax_compat'] === 'XMLRPC')
{
self::$_instance->request_method = 'XMLRPC';
} }
} }
} }
@ -1197,13 +1200,11 @@ class Context
self::set($key, $val, $set_to_vars); self::set($key, $val, $set_to_vars);
} }
// Set XMLRPC request parameters (Deprecated). // Set deprecated request parameters.
if(!$_POST && !empty($GLOBALS['HTTP_RAW_POST_DATA']))
{
if(self::getRequestMethod() === 'XMLRPC') if(self::getRequestMethod() === 'XMLRPC')
{ {
if($_POST || empty($GLOBALS['HTTP_RAW_POST_DATA']))
{
return;
}
if(!Rhymix\Framework\Security::checkXEE($GLOBALS['HTTP_RAW_POST_DATA'])) if(!Rhymix\Framework\Security::checkXEE($GLOBALS['HTTP_RAW_POST_DATA']))
{ {
header("HTTP/1.0 400 Bad Request"); header("HTTP/1.0 400 Bad Request");
@ -1225,6 +1226,18 @@ class Context
self::set($key, $val, true); self::set($key, $val, true);
} }
} }
elseif(self::getRequestMethod() === 'JSON')
{
$params = array();
parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params);
foreach($params as $key => $val)
{
$key = escape($key);
$val = self::_filterRequestVar($key, $val);
self::set($key, $val, true);
}
}
}
} }
/** /**