Solution for "PHP Warning: Input variables exceeded 1000"? #338

This commit is contained in:
the-djmaze 2022-04-20 22:49:42 +02:00
parent bf85675e42
commit 0ec49d0802
2 changed files with 20 additions and 17 deletions

35
dev/bootstrap.js vendored
View file

@ -3,6 +3,20 @@ import { i18n } from 'Common/Translator';
import { root } from 'Common/Links'; import { root } from 'Common/Links';
import { isArray } from 'Common/Utils';
const FormDataToObject = formData => {
var object = {};
formData.forEach((value, key) => {
if (!Reflect.has(object, key)){
object[key] = value;
} else {
isArray(object[key]) || (object[key] = [object[key]]);
object[key].push(value);
}
});
return object;
};
export default App => { export default App => {
rl.app = App; rl.app = App;
@ -42,23 +56,10 @@ export default App => {
}, init); }, init);
if (postData) { if (postData) {
init.method = 'POST'; init.method = 'POST';
init.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; init.headers['Content-Type'] = 'application/json';
const buildFormData = (formData, data, parentKey) => { postData = (postData instanceof FormData) ? FormDataToObject(postData) : postData;
if (data && typeof data === 'object' && !(data instanceof Date || data instanceof File)) { postData.XToken = Settings.app('token');
Object.keys(data).forEach(key => init.body = JSON.stringify(postData);
buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key)
);
} else {
formData.set(parentKey, data == null ? '' : data);
}
return formData;
};
postData = (postData instanceof FormData)
? postData
: buildFormData(new FormData(), postData);
postData.set('XToken', Settings.app('token'));
// init.body = JSON.stringify(Object.fromEntries(postData));
init.body = new URLSearchParams(postData);
} }
return fetch(resource, init); return fetch(resource, init);

View file

@ -91,6 +91,8 @@ class ServiceActions
$aResponseItem = null; $aResponseItem = null;
$oException = null; $oException = null;
$_POST = \json_decode(\file_get_contents('php://input'), true);
$sAction = $_POST['Action'] ?? null; $sAction = $_POST['Action'] ?? null;
if (empty($sAction) && $this->oHttp->IsGet() && !empty($this->aPaths[2])) if (empty($sAction) && $this->oHttp->IsGet() && !empty($this->aPaths[2]))
{ {