[SOLVED] Plugin Architecture v2.0 bug ?

Support for the Plugin Architecture

Moderators: Developers, Moderators

Post Reply
qantic
Posts: 4
Joined: Tue Sep 04, 2007 1:59 pm

[SOLVED] Plugin Architecture v2.0 bug ?

Post by qantic »

I upgraded to cacti 0.8.7b and plugin architecture 2.0 and my plugins (thold, weathermap) had url broken for console, graphs, ...

I have $config['url_path']="/"; setup in config.php but i had to modify include/plugins.php to get it working with the correct url.

at line 35 there's a "if" which is setting the value for $config['url_path'] in database. The issue for me, it's set as empty and it should be set as "/".

I don't investigate more and ugly patched the code inserting the value "/" in database in settings.url_path and i modified the code to do in the "if" part the same than in the "else" (SELECT ...).

That's a temp workaround, for people that have the same issue.

If jimmy can tell us if it's a real bug and patch it or if it's a setup issue on my side.
Tybio
Cacti User
Posts: 80
Joined: Thu Feb 16, 2006 8:14 am

Post by Tybio »

I fixed it on my Redhat server by squashing the fancy code in plugins.php. Here is exactly what I did:

Edit include/plugins.php

Add a static definition above the last 'define' line, such as:

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'");
}

$config['url_path'] = '/cacti/';

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


So nearly the same answer....kinda annoying :)
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Jimmy admited that he should not have attempted to "rediscover" that which should be specified by the administrator.

TheWitness
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?
zeki
Cacti User
Posts: 92
Joined: Fri Feb 09, 2007 10:55 pm
Location: So. Cal
Contact:

Post by zeki »

thanx tybio adding that line fixed mine :D
tin
Posts: 2
Joined: Thu Feb 21, 2008 5:17 am

Post by tin »

Phew! Thank God for that!!! I (foolishly) slapped plugin 2.0 over a new cacti install this morning that I want to use in a couple of hours! :oops: Thanks to those that posted here.

Spent most of the morning trying to figure why it decided to append a "/i" after my defined url_path in config.php - for some reason plugins.php is not one of the places I looked (fairly green with cacti, more green with plugins and VERY green with PHP)

Turns out it does not append, seemingly the "fancy schmancy stuff" (heheh) just blats right over my configured value - It does almost get it right too, at least in my install. It always comes up with /cacti/i/ no matter if I define url_path in config.php or not (or indeed as I did at one point, define it as "/argh-its/broke/").
thavinci
Posts: 26
Joined: Tue Nov 06, 2007 12:14 pm
Location: JHB
Contact:

Wow - holy cr....

Post by thavinci »

Man this was a nasty suprise!
It seems new version of cacti was broken and had to jippo it, and after i managed to get that going i tried the plug-in infrastructure.

My entire installation went down the drain.
Seems now the url path had a "de" added between, tried setting my path with the old

(ie what used to be "http://www.thavinci.za.net/monitor/
now was http://www.thavinci.za.net/monitor/de)

$config['url_path'] = '/monitor/';

story but didn't work eventually just restored what i had!

This was a BAD upgrade attempt, every package seems to need a hack to work.....
thavinci
Posts: 26
Joined: Tue Nov 06, 2007 12:14 pm
Location: JHB
Contact:

More ppl with same issue

Post by thavinci »

http://cactiusers.org/forums/viewtopic. ... poller+ran


Great software, can't wait for next stable release.
nifi
Posts: 15
Joined: Sun Aug 06, 2006 8:08 pm
Location: zhengzhou.china

thanks

Post by nifi »

i have the same error,follow tybio's way,i solved it!
thanks!
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

I had a similar problem with some plugins and PA2.0 and windows.
My problem was that in windows the / is converted automaticâlly by plugins.php to \ .
1/ But This is wrong for SQL request --> CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1064', SQL:"REPLACE INTO settings (name, value) VALUES ('url_path', '\')
2/ some plugins had problem with this and have seen the wrong url.

Because I have windows I had to do in plugins.php this:

Code: Select all

  $search= array('\\');
  $replace='/';
  $config['url_path']= str_replace($search,$replace,$config['url_path']);
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
laamidd
Posts: 48
Joined: Fri Feb 17, 2006 10:31 am

Post by laamidd »

Thanks Pepj, I was getting the same error in my logs:

CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1064', SQL:"REPLACE INTO settings (name, value) VALUES ('url_path', '\')

I'm on windows too.

I added your hack in plugins.php:

Code: Select all

$search= array('\\');
  $replace='/';
  $config['url_path']= str_replace($search,$replace,$config['url_path']); 
right before this line:

Code: Select all

define('URL_PATH', $config['url_path']);
That works for me!

Thanks again,
Bob
Ptica79
Posts: 3
Joined: Tue Mar 11, 2008 9:40 am

Post by Ptica79 »

I propose use

Code: Select all

addslashes
(PHP 3, PHP 4, PHP 5)

addslashes -- Quote string with slashes
Description
string addslashes ( string str )


Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte). 

Code: Select all

	db_execute("REPLACE INTO settings (name, value) VALUES ('url_path', '" . addslashes($config['url_path']) . "')");
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest