Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

nuRunPHPHiddenWithParams doesn't work after update

Questions related to installing, updating, setting up and configuring
Post Reply
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Contact:

nuRunPHPHiddenWithParams doesn't work after update

Unread post by kknm »

Before the update, this function worked on the form

Code: Select all

nuRunPHPHiddenWithParams('ADJP', 'param', {dat: dat, wor: wor, pr: pr, dep: dep, comp: comp, kart: kart, kom: kom, str: str, id: id, coun: coun},0);
nuMessage shows shows all input data,but is not included in the ADJP procedure, because nuDebug does not appear.
PHP('ADJP'):

Code: Select all

nuDebug('#param#');
$param = json_decode(base64_decode('#param#')); // retrieve the parameters

$dep = $param->dep;
$comp = $param->comp;

$dat = $param->dat;
$d = new DateTime($dat);
$dat = $d->format('Y-m-d');

$wor =$param->wor;
$kom =$param->kom;
$str =$param->str;
$pr = $param->pr;
$ka = $param->kart;
$id = $param->id;
$count = $param->coun;

        if (empty($dat) or empty($dep) or empty($wor)) {
            nuDisplayError('Не заполнены данные !, дата= '.$dat.' отдел='.$dep.' работа= '.$wor);
        } else {
        	$uid=nuID();
            $x="INSERT INTO jurprint (jur_pid, jurp_data, jurp_work, jurp_pr, jurp_kart, jurp_dep, jurp_comp, jurp_komm, jurp_itog) VALUES ('$uid', '$dat','$wor', '$pr', '$ka', '$dep', '$comp', '$kom', '$str' )";
            nuRunQuery($x);
            $x = "UPDATE prints SET total='$str', count='$count',data='$dat'  WHERE pr_id='$id';";
            nuRunQuery($x);
        }    
kev1n
nuBuilder Team
Posts: 3987
Joined: Sun Oct 14, 2018 6:43 pm
nuBuilder Version: 4.5
Has thanked: 5 times
Been thanked: 14 times
Contact:

Re: nuRunPHPHiddenWithParams doesn't work after update

Unread post by kev1n »

Try it with this function:

Code: Select all

function nuRunPHPHiddenWithParams(i, paramName, paramValue, rbs) {
	nuSetProperty(paramName, nuBase64encode(JSON.stringify(paramValue)));
	nuRunPHPHidden(i, rbs);
}
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Contact:

Re: nuRunPHPHiddenWithParams doesn't work after update

Unread post by kknm »

nuDebug:
[0] : BxZkYXQWAxYyMDIzLTExLTE0FgIWd29yFgMWAGEAAAAAAAAAAAAAFAAAAAAAUABSAFAAAAAAAAAAABYCFnByFgMWQ2Fub24UTEJQNjAwMBYCFmRlcBYDFgAJAF0ACRYCFmNvbXAWAxZPR01fWkFNFgIWa2FydBYDFjcyNRYCFmtvbRYDFhYCFnN0chYDFjIyNjQxFgIWaWQWAxY2MDVjNzBiNzM5NDMxM2IWAhZjb3VuFgMWMTUyNxYH

PHP('ADJP') returns :
('Не заполнены данные !, дата=2023-11-14 , отдел='', работа='')

those. only the first parameter was decoded
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Contact:

Re: nuRunPHPHiddenWithParams doesn't work after update

Unread post by kknm »

Should I wait for an answer on nuRunPHPHiddenWhithParams?
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Contact:

Re: nuRunPHPHiddenWithParams doesn't work after update

Unread post by kknm »

I conducted a series of experiments and found out that before the update, the PHP base64_decode('#param#') function worked correctly with the Cyrillic alphabet in #param#, but after the update it crashed with an error. With #param# in English, this PHP function works correctly.
Example:
js

Code: Select all

dat=2023-11-15;
wor=Replace;
pr=Canon LBP6000;
 nuRunPHPHiddenWhithParams('ADJP', param,{dat:dat,wor:wor, pr:pr},0);
Result PHP:

Code: Select all

$param = base64_decode('#param#');
nuDisplayErrors("zip = ".$param)
zip = {"dat":"2023-11-15","wor":"Replace","pr":"Canon LBP6000"}
************************************************
Example_2:
js

Code: Select all

dat=2023-11-15;
wor=Замена; //cyrillic !
pr=Canon LBP6000;
 nuRunPHPHiddenWhithParams('ADJP', param,{dat:dat,wor:wor, pr:pr},0);
PHP:

Code: Select all

nuDebug('#param#');
//$param = json_decode(base64_decode('#param#')); 
$param = base64_decode('#param#');
nuDisplayError("zip = ".$param);
*********
the nuRunPHPHiddenWhithParams function does not work at all because nuDebug('Hello') even on the first line PHP doesn't work.
kev1n
nuBuilder Team
Posts: 3987
Joined: Sun Oct 14, 2018 6:43 pm
nuBuilder Version: 4.5
Has thanked: 5 times
Been thanked: 14 times
Contact:

Re: nuRunPHPHiddenWithParams doesn't work after update

Unread post by kev1n »

it crashed with an error
Can you show the error ?
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Contact:

Re: nuRunPHPHiddenWithParams doesn't work after update

Unread post by kknm »

I can't show the error because nothing appears in the nuDebug log with cyrillic parameters. With English parameters, nuDebug and nuDysplayErrors appear.
kev1n
nuBuilder Team
Posts: 3987
Joined: Sun Oct 14, 2018 6:43 pm
nuBuilder Version: 4.5
Has thanked: 5 times
Been thanked: 14 times
Contact:

Re: nuRunPHPHiddenWithParams doesn't work after update

Unread post by kev1n »

This seems to work for me:

JS:

Code: Select all

function utf8_to_b64(str) {
    return btoa(unescape(encodeURIComponent(str)));
}
function nuRunPHPHiddenWithParams(i, paramName, paramValue, rbs) {
	nuSetProperty(paramName, utf8_to_b64(JSON.stringify(paramValue)));
	nuRunPHPHidden(i, rbs);
}
var dat='2023-11-15';
var wor='Замена'; //cyrillic !
var pr='Canon LBP6000';
 nuRunPHPHiddenWithParams('ADJP', 'param',{dat:dat,wor:wor, pr:pr},0);
 
PHP:

Code: Select all

function decodeEncodedString($encodedString) {
    $decodedString = base64_decode($encodedString);
    $decodedArray = json_decode($decodedString, true);
    return $decodedArray;
}

$result = decodeEncodedString('#param#');
if ($result != null) {
    // Retrieve values
    $dat = $result['dat'];
    $wor = $result['wor'];
    $pr = $result['pr'];

    // Output the result
    nuDisplayError("dat: $dat, wor: $wor, pr: $pr");

}
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Contact:

Re: nuRunPHPHiddenWithParams doesn't work after update

Unread post by kknm »

Thank you, everything works like clockwork!
Post Reply