Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Problems installing PIA 2.1 on Cacti 0.8.7b + solution

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin Architecture
Author Message
djee



Joined: 28 May 2008
Posts: 2

PostPosted: Wed May 28, 2008 9:48 am    Post subject: Problems installing PIA 2.1 on Cacti 0.8.7b + solution Reply with quote

I installed the above on a Debian system (although i doubt this is the cause of the problems), but not with the apt packaging system (as i wanted the PIA, which is not packaged yet for Debian). I had below two issues after install and before adding any Plugin. The solutions are scattered around on this forum in bits and pieces, for your convenience i stuffed the two solutions in one post

1) "Invalid PHP_SELF Path" when browsing to http://server/cacti

This can be solved by editing include/global.php, lookup the following code snippet:

Code:

/* Sanity Check on "Corrupt" PHP_SELF */
if ((!is_file($_SERVER["PHP_SELF"])) && (!is_file($config["base_path"] . '/' . $_SERVER["PHP_SELF"]))) {
                if (!is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["PHP_SELF"])) {
                        if (!((is_file($_SERVER["SCRIPT_FILENAME"])) && (substr_count($_SERVER["SCRIPT_FILENAME"],
$_SERVER["PHP_SELF"])))) {
                                echo "\nInvalid PHP_SELF Path\n";
                                exit;
                        }
                }
}


and just comment it out, e.g. like this :
Code:

/* Sanity Check on "Corrupt" PHP_SELF */
/* COMMENTED OUT DUE TO FAIL FOR ALIAS */
/*
if ((!is_file($_SERVER["PHP_SELF"])) && (!is_file($config["base_path"] . '/' . $_SERVER["PHP_SELF"]))) {
                if (!is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["PHP_SELF"])) {
                        if (!((is_file($_SERVER["SCRIPT_FILENAME"])) && (substr_count($_SERVER["SCRIPT_FILENAME"],
$_SERVER["PHP_SELF"])))) {
                                echo "\nInvalid PHP_SELF Path\n";
                                exit;
                        }
                }
}
*/


I understand this is a security feature that checks against the source URI, but I don't think it will ever pass when using an alias. Please let me know if it does and how I should put it to work properly (and yes, i already adapted $config['url_path'] )

2) "...cacti Passed variable is not an array..." when browsing to http://server/cacti

This was solved by editing lib/functions.php, find the following function

Code:

/* read_default_config_option - finds the default value of a Cacti configuration setting
   @arg $config_name - the name of the configuration setting as specified $settings array
     in 'include/global_settings.php'
   @returns - the default value of the configuration option */
function read_default_config_option($config_name) {
        global $config, $settings;

        reset($settings);
        while (list($tab_name, $tab_array) = each($settings)) {
                if ((isset($tab_array[$config_name])) && (isset($tab_array[$config_name]["default"]))) {
                        return $tab_array[$config_name]["default"];
                }else{
                        while (list($field_name, $field_array) = each($tab_array)) {
                                if ((isset($field_array["items"])) && (isset($field_array["items"][$config_name]))
&& (isset($field_array["items"][$config_name]["default"]))) {
                                        return $field_array["items"][$config_name]["default"];
                                }
                        }
                }
        }
}


And add a check as follows:

Code:

/* read_default_config_option - finds the default value of a Cacti configuration setting
   @arg $config_name - the name of the configuration setting as specified $settings array
     in 'include/global_settings.php'
   @returns - the default value of the configuration option */
function read_default_config_option($config_name) {
        global $config, $settings;
        if (is_array($settings)) {
        reset($settings);
        while (list($tab_name, $tab_array) = each($settings)) {
                if ((isset($tab_array[$config_name])) && (isset($tab_array[$config_name]["default"]))) {
                        return $tab_array[$config_name]["default"];
                }else{
                        while (list($field_name, $field_array) = each($tab_array)) {
                                if ((isset($field_array["items"])) && (isset($field_array["items"][$config_name]))
&& (isset($field_array["items"][$config_name]["default"]))) {
                                        return $field_array["items"][$config_name]["default"];
                                }
                        }
                }
        }
        }
}


This made my installation work, feel free to post any "better ways", fixes, patches i missed, ...
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9697
Location: MI, USA

PostPosted: Thu May 29, 2008 8:33 pm    Post subject: Reply with quote

I believe that there is already a patch for this

TheWitness
Back to top
djee



Joined: 28 May 2008
Posts: 2

PostPosted: Sun Jun 01, 2008 4:08 pm    Post subject: Reply with quote

Ok, was afraid that one was coming. I had a deeper look into the "official patches" section.
"Patch to Correct for a Uninitialized Settings Array When Using Superlinks Plugin" indeed is the fix for the second problem. The name of the patch however suggests the problem only occurs when using Superlinks plugin, but i had the problem already when no plugins were installed at all.

I don't find a patch that fixes the first problem however ... If you happen to have some more insight in the exact function of that check, i'm very interested also !

Greets,
djee
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin Architecture All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group