$config['url_path'] is not evaluated in plugin scripts

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
format_c
Posts: 11
Joined: Fri Aug 17, 2007 7:49 am

$config['url_path'] is not evaluated in plugin scripts

Post by format_c »

Hi,

Cacti seems to work well. But opening a plugin (e.g. monitor) styles look wrong. Seems the $config['url_path'] variable isnt evaluated that compensates the plugin path in the url. poller.php for example includes global.php which includes config.php where the variable is set. But the second include seems not to be executed.

Do I have to set something special in php5?

Cheers Alex
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Re: $config['url_path'] is not evaluated in plugin scripts

Post by pepj »

format_c wrote:Hi,
$config['url_path'] variable isnt evaluated
look at www.cactiusers.net
URL=http://cactiusers.org/forums/viewtopic.php?p=5181#5181
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
format_c
Posts: 11
Joined: Fri Aug 17, 2007 7:49 am

Post by format_c »

Mhh in the posts the problem seems not to be solved; just described?

Cheers Alex
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

format_c wrote:Mhh in the posts the problem seems not to be solved; just described?
I had not really good explain how to solve it because I wanted Gigamit/Jimmy give a answer (and perhaps a better solution).

How to solve --->
in "plugings.php"
relpace:

Code: Select all

if (isset($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['REMOTE_ADDR'])) {
	$config['url_path'] = substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT']), strlen(__FILE__) - strlen($_SERVER['DOCUMENT_ROOT']) - strlen('include/plugins.php'));
	db_execute("REPLACE INTO settings (name, value) VALUES ('url_path', '" . $config['url_path'] . "')");
} else {
	$config['url_path'] = db_fetch_cell("SELECT value FROM settings WHERE name = 'url_path'");
}

define('URL_PATH', $config['url_path']);
with

Code: Select all

if (isset($_SERVER['DOCUMENT_ROOT']) && isset($_SERVER['REMOTE_ADDR'])) {
	$config['url_path'] = substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT']), strlen(__FILE__) - strlen($_SERVER['DOCUMENT_ROOT']) - strlen('include/plugins.php'));
  $search= array('\\');
  $replace='/';
  $config['url_path']= str_replace($search,$replace,$config['url_path']);
	db_execute("REPLACE INTO settings (name, value) VALUES ('url_path', '" . $config['url_path'] . "')");
} else {
	$config['url_path'] = db_fetch_cell("SELECT value FROM settings WHERE name = 'url_path'");
}

define('URL_PATH', $config['url_path']);
[/b]
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
format_c
Posts: 11
Joined: Fri Aug 17, 2007 7:49 am

Post by format_c »

Mhh I do not have such a sniplet in my plugins.php.
I am Using cacti-plugin-arch 0.8.7b.

Cacti has also version 0.8.7b.

I do not understand what I am doing wrong.

cheers Alex
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

format_c wrote:Mhh I do not have such a sniplet in my plugins.php.
I am Using cacti-plugin-arch 0.8.7b.
Cacti has also version 0.8.7b.
I do not understand what I am doing wrong.
file "plugins.php" delivered in PA 2.0
http://cactiusers.org/downloads/patches/
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests