Location: PHPKode > projects > Cancerbero - The watchdog of the ports > cancerbero-0.6/site/include/update_2_3.php
<?php

# Spript to change a cancerbero's database version 2 to version 3


include_once("dbconnect.php");


$database_ver = 3;

$upgrade_version = mysql_query("UPDATE `configuration` SET `database_ver` = ( -1 ) * `database_ver` WHERE 1") or die (mysql_error());

$query = mysql_query ("UPDATE `nmap_cfg` SET `nmap_type_cfg` = 'Scantmp' WHERE `nmap_option_name` = 'Polite' AND `nmap_cmd_cfg` LIKE '-A %'") or die (mysql_error());
$query = mysql_query ("UPDATE `nmap_cfg` SET `nmap_type_cfg` = 'Scantmp' WHERE `nmap_option_name` = 'Normal' AND `nmap_cmd_cfg` LIKE '-A %'") or die (mysql_error());
$query = mysql_query ("UPDATE `nmap_cfg` SET `nmap_type_cfg` = 'Scantmp' WHERE `nmap_option_name` = 'Aggressive' AND `nmap_cmd_cfg` LIKE '-A %'") or die (mysql_error());
$query = mysql_query ("UPDATE `nmap_cfg` SET `nmap_type_cfg` = 'Sweep' WHERE `nmap_option_name` = 'Polite' AND `nmap_cmd_cfg` LIKE '-sP %'") or die (mysql_error());
$query = mysql_query ("UPDATE `nmap_cfg` SET `nmap_type_cfg` = 'Sweep' WHERE `nmap_option_name` = 'Normal' AND `nmap_cmd_cfg` LIKE '-sP %'") or die (mysql_error());
$query = mysql_query ("UPDATE `nmap_cfg` SET `nmap_type_cfg` = 'Sweep' WHERE `nmap_option_name` = 'Aggressive' AND `nmap_cmd_cfg` LIKE '-sP %'") or die (mysql_error());
$query = mysql_query ("UPDATE `nmap_cfg` SET `nmap_type_cfg` = 'Scan' WHERE `nmap_option_name` = 'Polite' AND `nmap_cmd_cfg` LIKE '-A %'") or die (mysql_error());
$query = mysql_query ("UPDATE `nmap_cfg` SET `nmap_type_cfg` = 'Scan' WHERE `nmap_option_name` = 'Normal' AND `nmap_cmd_cfg` LIKE '-A %'") or die (mysql_error());
$query = mysql_query ("UPDATE `nmap_cfg` SET `nmap_type_cfg` = 'Scan' WHERE `nmap_option_name` = 'Aggressive' AND `nmap_cmd_cfg` LIKE '-A %'") or die (mysql_error());

$sensors = mysql_query ("SELECT sensor_id,sensor_nmap_sweep_opts,sensor_nmap_opts FROM sensors") or die (mysql_error());

while ($sensor = mysql_fetch_assoc($sensors)) {
	$sensor_id = $sensor['sensor_id'];
	if ($sensor['sensor_nmap_sweep_opts'] <= 6) {
		$new_nmap_sweep_opts = $sensor['sensor_nmap_sweep_opts']+3;
		$update_sensor_sweep = mysql_query ("UPDATE `sensors` SET `sensor_nmap_sweep_opts` = $new_nmap_sweep_opts WHERE sensor_id = $sensor_id") or die (mysql_error());
	}
	if ($sensor['sensor_nmap_opts'] <= 6) {
		$new_nmap_opts = $sensor['sensor_nmap_opts']-3;
		$update_sensor_scan = mysql_query ("UPDATE `sensors` SET `sensor_nmap_opts` = $new_nmap_opts WHERE sensor_id = $sensor_id") or die (mysql_error());
	}
}

$ranges = mysql_query ("SELECT range_id,range_nmap_opts FROM ranges") or die (mysql_error());

while ($range = mysql_fetch_assoc($ranges)) {
	$range_id = $range['range_id'];
	if ($range['range_nmap_opts'] <=6){
		$new_range_nmap_opts = $range['range_nmap_opts']-3;
		$update_range_scan = mysql_query ("UPDATE `ranges` SET `range_nmap_opts` = $new_range_nmap_opts WHERE range_id = $range_id") or die (mysql_error());
	}
}

$upgrade_version = mysql_query("UPDATE configuration SET database_ver= $database_ver") or die (mysql_error());

?>
Return current item: Cancerbero - The watchdog of the ports