Question about Configuration Wizards - Passing Variables

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Question about Configuration Wizards - Passing Variables

Post by Box293 »

I'm not a programmer by trade, I don't understand how some things work in the configuration wizards.

When passing collected variables through the wizard, why do I need to serialize array variables but not basic ones?

Example:
$services gets serialized

Code: Select all

case CONFIGWIZARD_MODE_GETSTAGE3HTML:
// get variables that were passed to us
$address=grab_array_var($inargs,"address");
$services=grab_array_var($inargs,"services");
$output='
<input type="hidden" name="services_serial" value="'.base64_encode(serialize($services)).'">
And then unserialized

Code: Select all

case CONFIGWIZARD_MODE_GETOBJECTS:
$address=grab_array_var($inargs,"address","");
$services_serial=grab_array_var($inargs,"services_serial","");
$services=unserialize(base64_decode($services_serial));
I have played around and if I don't serialize then the data does not get passed on. The $address variable seems fine without any serialization.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Question about Configuration Wizards - Passing Variables

Post by mguthrie »

I don't know off the top of my head, I haven't written a wizard yet, but my guess would be that the functions are expecting a certain data type (string, floating point number, or integer), and having an array with mixed data types probably messes things up when it gets processed. You could look up the base64_encode() function on php.net and see what the details are on it.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Question about Configuration Wizards - Passing Variables

Post by mmestnik »

Mike's on the correct path. The data flows through HTTP's POST handler, but to get there it's placed into an HTML input element of type hidden. Thus it MUST be a string, this is the process of converting the array into a string for this purpose.

Future Wizards will hopefully be mostly JavaScript and only submit jobs to the CCM engine for processing. Time will tell.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Question about Configuration Wizards - Passing Variables

Post by Box293 »

Thanks both for your reponses.

I now understand clearly what is going on.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked