function setUserLang() { $contents = read_cgi_config_file(); $user = $_SERVER['REMOTE_USER']; $locale_lang_path = $contents['locale_lang_path']; $locale_lang_user = $contents['locale_lang_user']; foreach (explode(",", $locale_lang_user) as $val) { $arr = explode("|", $val); if ($arr[0] == $user) { $locale_lang_user_lang = $arr[1]; } } //echo $locale_lang_user_lang; //echo $locale_lang_path; $LANG_FILE = $locale_lang_path . "/" . $locale_lang_user_lang . "/LC_MESSAGES/nagios-plugins.mo"; return $LANG_FILE; /*putenv("LC_ALL=".$locale_lang_user_lang); putenv("LANG=".$locale_lang_user_lang); bindtextdomain("nagios-plugins", $locale_lang_path); textdomain("nagios-plugins");*/ }
function get_update_information() { global $cfg; // initialize array $updateinfo = array("found_update_info" => false, "update_checks_enabled" => true, "last_update_check" => "", "update_available" => false, "update_version" => ""); // first read CGI config file to determine main file location $ccfc = read_cgi_config_file(); //print_r($ccfc); // read main config file to determine file locations if (isset($ccf['main_config_file'])) { $mcf = $ccf['main_config_file']; } else { $mcf = ""; } $mcfc = read_main_config_file($mcf); //print_r($mcfc); if (isset($mcf['status_file'])) { $sf = $mcf['status_file']; } else { $sf = ""; } if (isset($mcf['state_retention_file'])) { $rf = $mcf['state_retention_file']; } else { $rf = ""; } /////////////////////////////////////////////// // GET PROGRAM VARIABLES FROM MAIN CONFIG FILE /////////////////////////////////////////////// // are update checks enabled? if (isset($mcfc['check_for_updates']) && $mcfc['check_for_updates'] == "0") { $updateinfo["update_checks_enabled"] = false; } ///////////////////////////////////////// // DETERMINE UPDATE INFO FROM STATUS FILE ///////////////////////////////////////// // read status file (just first few lines) $sfc = read_status_file($sf, 50); //print_r($sfc); //exit(); // last update time if (isset($sfc['info']['last_update_check'])) { $updateinfo["last_update_check"] = $sfc['info']['last_update_check']; $updateinfo["found_update_info"] = true; } // update available if (isset($sfc['info']['update_available'])) { if ($sfc['info']['update_available'] == "1") { $updateinfo["update_available"] = true; } else { $updateinfo["update_available"] = false; } } // update version if (isset($sfc['info']['new_version'])) { $updateinfo["update_version"] = $sfc['info']['new_version']; } // did we find update information in the status file? if so, we're done if ($updateinfo["found_update_info"] == true) { return $updateinfo; } //////////////////////////////////////////// // DETERMINE UPDATE INFO FROM RETENTION FILE //////////////////////////////////////////// // Nagios might be shutdown (ie, no status file), so try and read data from the retention file // read retentiion file (just first few lines) $rfc = read_retention_file($rf, 50); //print_r($rfc); //exit(); // last update time if (isset($rfc['info']['last_update_check'])) { $updateinfo["last_update_check"] = $rfc['info']['last_update_check']; $updateinfo["found_update_info"] = true; } // update available if (isset($rfc['info']['update_available'])) { if ($rfc['info']['update_available'] == "1") { $updateinfo["update_available"] = true; } else { $updateinfo["update_available"] = false; } } // update version if (isset($rfc['info']['new_version'])) { $updateinfo["update_version"] = $rfc['info']['new_version']; } return $updateinfo; }