upgrades, this installation is already up-to-date. Click here to use cacti.";
exit;
}elseif (ereg("^0\.6", $old_cacti_version)) {
print "
Error
You are attempting to install cacti " . $config["cacti_version"] . "
onto a 0.6.x database. To continue, you must create a new database, import 'cacti.sql' into it, and
update 'include/config.php' to point to the new database.
You have created a new database, but have not yet imported
the 'cacti.sql' file. At the command line, execute the following to continue:
mysql -u $database_username -p $database_default < cacti.sql
";
exit;
}
function db_install_execute($cacti_version, $sql) {
$sql_install_cache = (isset($_SESSION["sess_sql_install_cache"]) ? $_SESSION["sess_sql_install_cache"] : array());
if (db_execute($sql)) {
$sql_install_cache{sizeof($sql_install_cache)}[$cacti_version][1] = $sql;
}else{
$sql_install_cache{sizeof($sql_install_cache)}[$cacti_version][0] = $sql;
}
$_SESSION["sess_sql_install_cache"] = $sql_install_cache;
}
function find_best_path($binary_name) {
$search_paths = array("/bin", "/sbin", "/usr/bin", "/usr/sbin", "/usr/local/bin", "/usr/local/sbin");
for ($i=0; $i") {
$input["path_rrdtool"]["default"] = read_config_option("path_rrdtool");
}else{
$input["path_rrdtool"]["default"] = "/usr/local/bin/rrdtool";
}
}elseif ($config["cacti_server_os"] == "win32") {
$input["path_rrdtool"]["default"] = "c:/rrdtool/rrdtool.exe";
}
/* PHP Binary Path */
$input["path_php_binary"] = $settings["path"]["path_php_binary"];
if ($config["cacti_server_os"] == "unix") {
$which_php = find_best_path("php");
if (!empty($which_php)) {
$input["path_php_binary"]["default"] = $which_php;
}elseif (read_config_option("path_php_binary") != "") {
$input["path_php_binary"]["default"] = read_config_option("path_php_binary");
}else{
$input["path_php_binary"]["default"] = "/usr/bin/php";
}
}elseif ($config["cacti_server_os"] == "win32") {
$input["path_php_binary"]["default"] = "c:/php/php.exe";
}
/* snmpwalk Binary Path */
if ($config["cacti_server_os"] == "unix") {
$input["path_snmpwalk"] = $settings["path"]["path_snmpwalk"];
$which_snmpwalk = find_best_path("snmpwalk");
if (!empty($which_snmpwalk)) {
$input["path_snmpwalk"]["default"] = $which_snmpwalk;
}elseif (read_config_option("path_snmpwalk") != "") {
$input["path_snmpwalk"]["default"] = read_config_option("path_snmpwalk");
}else{
$input["path_snmpwalk"]["default"] = "/usr/local/bin/snmpwalk";
}
}
/* snmpget Binary Path */
if ($config["cacti_server_os"] == "unix") {
$input["path_snmpget"] = $settings["path"]["path_snmpget"];
$which_snmpget = find_best_path("snmpget");
if (!empty($which_snmpget)) {
$input["path_snmpget"]["default"] = $which_snmpget;
}elseif (read_config_option("path_snmpget") != "") {
$input["path_snmpget"]["default"] = read_config_option("path_snmpget");
}else{
$input["path_snmpget"]["default"] = "/usr/local/bin/snmpget";
}
}
/* log file path */
$input["path_cactilog"] = $settings["path"]["path_cactilog"];
$input["path_cactilog"]["description"] = "The path to your Cacti log file.";
$input["path_cactilog"]["default"] = $config["base_path"] . "/log/cacti.log";
/* SNMP Version */
if ($config["cacti_server_os"] == "unix") {
$input["snmp_version"] = $settings["general"]["snmp_version"];
$input["snmp_version"]["default"] = "net-snmp";
}
/* default value for this variable */
if (!isset($_REQUEST["install_type"])) {
$_REQUEST["install_type"] = 0;
}
/* defaults for the install type dropdown */
if ($old_cacti_version == "new_install") {
$default_install_type = "1";
}else{
$default_install_type = "3";
}
/* pre-processing that needs to be done for each step */
if (empty($_REQUEST["step"])) {
$_REQUEST["step"] = 1;
}else{
if ($_REQUEST["step"] == "1") {
$_REQUEST["step"] = "2";
}elseif (($_REQUEST["step"] == "2") && ($_REQUEST["install_type"] == "1")) {
$_REQUEST["step"] = "3";
}elseif (($_REQUEST["step"] == "2") && ($_REQUEST["install_type"] == "3")) {
$_REQUEST["step"] = "8";
}elseif (($_REQUEST["step"] == "8") && ($old_version_index <= array_search("0.8.5a", $cacti_versions))) {
$_REQUEST["step"] = "9";
}elseif ($_REQUEST["step"] == "8") {
$_REQUEST["step"] = "3";
}elseif ($_REQUEST["step"] == "9") {
$_REQUEST["step"] = "3";
}elseif ($_REQUEST["step"] == "3") {
$_REQUEST["step"] = "4";
}
}
if ($_REQUEST["step"] == "4") {
include_once("../lib/data_query.php");
include_once("../lib/utility.php");
$i = 0;
/* get all items on the form and write values for them */
while (list($name, $array) = each($input)) {
if (isset($_POST[$name])) {
db_execute("update settings set value='" . $_POST[$name] . "' where name='$name'");
}
}
setcookie(session_name(),"",time() - 3600,"/");
kill_session_var("sess_config_array");
kill_session_var("sess_host_cache_array");
/* just in case we have hard drive graphs to deal with */
run_data_query(db_fetch_cell("select id from host where hostname='127.0.0.1'"), 6);
/* it's always a good idea to re-populate the poller cache to make sure everything is refreshed and
up-to-date */
repopulate_poller_cache();
db_execute("delete from version");
db_execute("insert into version (cacti) values ('" . $config["cacti_version"] . "')");
header ("Location: ../index.php");
exit;
}elseif (($_REQUEST["step"] == "8") && ($_REQUEST["install_type"] == "3")) {
/* if the version is not found, die */
if (!is_int($old_version_index)) {
print "
Error
Invalid Cacti version
$old_cacti_version, cannot upgrade to " . $config["cacti_version"] . "
";
exit;
}
/* loop from the old version to the current, performing updates for each version in between */
for ($i=($old_version_index+1); $i 0.8.5a */
}elseif ($cacti_versions[$i] == "0.8.6") {
include ("0_8_5a_to_0_8_6.php");
upgrade_to_0_8_6();
}elseif ($cacti_versions[$i] == "0.8.6a") {
include ("0_8_6_to_0_8_6a.php");
upgrade_to_0_8_6a();
if ($old_cacti_version == "0.8.6") {
/* no database upgrades for 0.8.6 -> 0.8.6a */
$_REQUEST["step"] = "3";
}
}elseif ($cacti_versions[$i] == "0.8.6b") {
if ($old_cacti_version == "0.8.6a") {
/* no database upgrades for 0.8.6a -> 0.8.6b */
$_REQUEST["step"] = "3";
}
}
}
}
?>
cacti