raphac
18 Jun 2009, 10:18 AM
I use the extension: Ext.ux.grid.KeyNav
When I press the key "down" (next page), rapidly and several times,
the $_POST receives several times the same method and parameters.
Ex.:
[{"action":"Controleacesso_UserController","method":"getall","data":[{"start":10,"limit":10,"sort":"m001usr_login"
,"dir":"ASC"}],"type":"rpc","tid":4},{"action":"Controleacesso_UserController","method":"getall","data"
:[{"start":10,"limit":10,"sort":"m001usr_login","dir":"ASC"}],"type":"rpc","tid":5},{"action":"Controleacesso_UserController"
,"method":"getall","data":[{"start":10,"limit":10,"sort":"m001usr_login","dir":"ASC"}],"type":"rpc","tid"
:6},{"action":"Controleacesso_UserController","method":"getall","data":[{"start":10,"limit":10,"sort"
:"m001usr_login","dir":"ASC"}],"type":"rpc","tid":7},{"action":"Controleacesso_UserController","method"
:"getall","data":[{"start":10,"limit":10,"sort":"m001usr_login","dir":"ASC"}],"type":"rpc","tid":8}]
The solution was:
protected function _getDirect(){
$isForm = false;
$isUpload = false;
if(!isset($HTTP_RAW_POST_DATA)){
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
if(isset($HTTP_RAW_POST_DATA)){
header('Content-Type: text/javascript');
$data = json_decode($HTTP_RAW_POST_DATA);
}else if(isset($_POST['extAction'])){ // form post
$isForm = true;
$isUpload = $_POST['extUpload'] == 'true';
$data = new BogusAction();
$data->action = $_POST['extAction'];
$data->method = $_POST['extMethod'];
$data->tid = $_POST['extTID'];
$data->data = array($_POST, $_FILES);
}else{
die('Invalid request.');
}
$response = null;
if(is_array($data)){
$response = array();
$m = array();
foreach($data as $d){
if(!in_array($d->method, $m)){
$m[] = $d->method;
$response[] = $this->_doRpc($d);
}
}
}else{
$response = $this->_doRpc($data);
}
if($isForm && $isUpload){
$ret = '<html><body><textarea>';
$ret .= json_encode($response);
$ret .= '</textarea></body></html>';
}else{
$ret = json_encode($response);
}
die($ret);
}
When I press the key "down" (next page), rapidly and several times,
the $_POST receives several times the same method and parameters.
Ex.:
[{"action":"Controleacesso_UserController","method":"getall","data":[{"start":10,"limit":10,"sort":"m001usr_login"
,"dir":"ASC"}],"type":"rpc","tid":4},{"action":"Controleacesso_UserController","method":"getall","data"
:[{"start":10,"limit":10,"sort":"m001usr_login","dir":"ASC"}],"type":"rpc","tid":5},{"action":"Controleacesso_UserController"
,"method":"getall","data":[{"start":10,"limit":10,"sort":"m001usr_login","dir":"ASC"}],"type":"rpc","tid"
:6},{"action":"Controleacesso_UserController","method":"getall","data":[{"start":10,"limit":10,"sort"
:"m001usr_login","dir":"ASC"}],"type":"rpc","tid":7},{"action":"Controleacesso_UserController","method"
:"getall","data":[{"start":10,"limit":10,"sort":"m001usr_login","dir":"ASC"}],"type":"rpc","tid":8}]
The solution was:
protected function _getDirect(){
$isForm = false;
$isUpload = false;
if(!isset($HTTP_RAW_POST_DATA)){
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
if(isset($HTTP_RAW_POST_DATA)){
header('Content-Type: text/javascript');
$data = json_decode($HTTP_RAW_POST_DATA);
}else if(isset($_POST['extAction'])){ // form post
$isForm = true;
$isUpload = $_POST['extUpload'] == 'true';
$data = new BogusAction();
$data->action = $_POST['extAction'];
$data->method = $_POST['extMethod'];
$data->tid = $_POST['extTID'];
$data->data = array($_POST, $_FILES);
}else{
die('Invalid request.');
}
$response = null;
if(is_array($data)){
$response = array();
$m = array();
foreach($data as $d){
if(!in_array($d->method, $m)){
$m[] = $d->method;
$response[] = $this->_doRpc($d);
}
}
}else{
$response = $this->_doRpc($data);
}
if($isForm && $isUpload){
$ret = '<html><body><textarea>';
$ret .= json_encode($response);
$ret .= '</textarea></body></html>';
}else{
$ret = json_encode($response);
}
die($ret);
}