Cacti 1.2.25: usage of validate_store_request_vars($filters, 'sess_ciscotools_mactrack');

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Developers, Moderators

Post Reply
Rno
Cacti Pro User
Posts: 704
Joined: Wed Dec 07, 2011 9:19 am

Cacti 1.2.25: usage of validate_store_request_vars($filters, 'sess_ciscotools_mactrack');

Post by Rno »

Hello,
I try to setup a filter on a value on a page of type boolean, but I can't make it work!
here is my filter (it's the no_ip filter):

Code: Select all

   $filters = array(
		'rows' => array(
			'filter' => FILTER_VALIDATE_INT,
			'pageset' => true,
			'default' => '-1'
			),
		'page' => array(
			'filter' => FILTER_VALIDATE_INT,
			'default' => '1'
			),
		'sort_column' => array(
			'filter' => FILTER_DEFAULT,
			'default' => 'mac.id'
			),
		'sort_direction' => array(
			'filter' => FILTER_DEFAULT,
			'default' => 'ASC',
			),
		'switch' => array(
			'filter' => FILTER_DEFAULT,
			'pageset' => true,
			'default' => ''
			),
		'mac_address' => array(
			'filter' => FILTER_DEFAULT,
			'pageset' => true,
			'default' => ''
			),
		'ip_address' => array(
			'filter' => FILTER_DEFAULT,
			'pageset' => true,
			'default' => ''
			),
		'vlan' => array(
			'filter' => FILTER_DEFAULT,
			'pageset' => true,
			'default' => ''
			),
		'no_ip' => array(
			'filter' => FILTER_VALIDATE_BOOLEAN,
			'pageset' => true,
			'default' => false
			),
		'description' => array(
			'filter' => FILTER_DEFAULT,
			'pageset' => true,
			'default' => ''
			)
	);
Then I do that to use the value:

Code: Select all

$no_ip  = get_request_var_request("no_ip");

and on my page I do that (display):

Code: Select all

					<td nowrap style='white-space: nowrap;' width="1">
						&nbsp;No IP:&nbsp;
					</td>
					<td width="1">
						<input type="checkbox" name="no_ip" value="1" <?php ($no_ip=='1')?print " checked":print "" ?> >
					</td>
But I always get this error:
when I try to select my no_ip checkbox

Code: Select all

25/09/2023 14:35:50 - CMDPHP Validation Error, Variable:no_ip, Value:undefined Backtrace:  (/plugins/ciscotools/ciscotools_tab.php[68]:ciscotools_displaymac(), /plugins/ciscotools/display_mac.php[77]:validate_store_request_vars(), /lib/html_utility.php[712]:die_html_input_error(), /lib/html_validate.php[64]:cacti_debug_backtrace())
25/09/2023 14:35:55 - CMDPHP Validation Error, Variable:no_ip, Value:undefined Backtrace:  (/plugins/ciscotools/ciscotools_tab.php[68]:ciscotools_displaymac(), /plugins/ciscotools/display_mac.php[77]:validate_store_request_vars(), /lib/html_utility.php[712]:die_html_input_error(), /lib/html_validate.php[64]:cacti_debug_backtrace())
And my url has the field no_ip set to undefined
But if I set it up with true, then I get what I wan't, and I can clear it and still wokring.

Any help welcome
Test
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
Rno
Cacti Pro User
Posts: 704
Joined: Wed Dec 07, 2011 9:19 am

Re: Cacti 1.2.25: usage of validate_store_request_vars($filters, 'sess_ciscotools_mactrack');

Post by Rno »

I find it
Test
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Cacti 1.2.25: usage of validate_store_request_vars($filters, 'sess_ciscotools_mactrack');

Post by TheWitness »

Trial and error will get you there. Don't forget to create a pull request with your enhancements!
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests