function initializeCookieVariable($variable_name = "") { if ($variable_name == "") { $variable_name = "ui_" . str_replace(".php", "", basename($_SERVER["PHP_SELF"])); } $value = read_user_config_option($variable_name); if ($value != '') { $_SESSION["sess_cacti_ui_" . $variable_name] = $value; ?> <script type="text/javascript"> <!-- alert(<?php print $variable_name;?>); var sess_cacti_ui_<?php print $variable_name . "=\"" . $value . "\"";?>; --> </script> <?php } }
/* user requests another language */ if (isset($_GET['language']) && isset($lang2locale[$_GET['language']])) { $cacti_locale = $_GET['language']; $cacti_country = $lang2locale[$_GET['language']]['country']; $_SESSION['language'] = $cacti_locale; /* save customized language setting (authenticated users only) */ set_user_config_option('language', $cacti_locale); /* language definition stored in the SESSION */ }elseif (isset($_SESSION['language']) && isset($lang2locale[$_SESSION['language']])){ $cacti_locale = $_SESSION['language']; $cacti_country = $lang2locale[$_SESSION['language']]['country']; /* look up for user customized language setting stored in Cacti DB */ }elseif ($user_locale = read_user_config_option('language')) { if(isset($lang2locale[$user_locale])) { $cacti_locale = $user_locale; $cacti_country = $lang2locale[$cacti_locale]['country']; $_SESSION['language'] = $cacti_locale; } /* detect browser settings if auto detection is enabled */ }elseif (read_config_option('i18n_auto_detection') && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $accepted = $_SERVER['HTTP_ACCEPT_LANGUAGE']; $accepted = strtolower(str_replace(strstr($accepted, ','), '', $accepted)); $accepted = (isset($lang2locale[$accepted])) ? $accepted : str_replace(strstr($accepted, '-'), '', $accepted); if (isset($lang2locale[$accepted])) {
} /* determine whether or not we can support a different time zone */ /* user requests another timezone (Validation is not required!)*/ if (isset($_GET['time_zone'])) { if(init_time_zone($_GET['time_zone'])) { set_user_config_option('time_zone', $_GET['time_zone']); $_SESSION['time_zone'] = $_GET['time_zone']; } /* time zone definition is stored in the SESSION */ }elseif (isset($_SESSION['time_zone'])) { init_time_zone($_SESSION['time_zone']); /* look up for user customized time zone stored in Cacti DB */ }elseif ($time_zone = read_user_config_option('time_zone')) { if(init_time_zone($time_zone)) { $_SESSION['time_zone'] = $time_zone; }; /* use the default time zone defined under "general" or fall back to sytsem time zone*/ }else { init_time_zone(read_config_option("i18n_default_timezone")); } /** * init_time_zone() - initialize the custom time zone * * @time_zone - custom time zone that has to be used * @return - returns true (successful) or false (failed)