mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Working in the new networkmaps.
This commit is contained in:
parent
69774bc4e2
commit
c5f6259fce
@ -35,6 +35,7 @@ abstract class Map {
|
|||||||
protected $height = null;
|
protected $height = null;
|
||||||
|
|
||||||
protected $nodes = null;
|
protected $nodes = null;
|
||||||
|
protected $edges = null;
|
||||||
|
|
||||||
protected $requires_js = null;
|
protected $requires_js = null;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class Networkmap extends Map {
|
|||||||
parent::processDBValues($dbValues);
|
parent::processDBValues($dbValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateDot($graph) {
|
protected function generateDot($graph, $positions) {
|
||||||
$graph = preg_replace('/^graph .*/', '', $graph);
|
$graph = preg_replace('/^graph .*/', '', $graph);
|
||||||
|
|
||||||
$nodes_and_edges = explode("];", $graph);
|
$nodes_and_edges = explode("];", $graph);
|
||||||
@ -70,9 +70,9 @@ class Networkmap extends Map {
|
|||||||
|
|
||||||
$chunks = explode("[", $node_or_edge);
|
$chunks = explode("[", $node_or_edge);
|
||||||
|
|
||||||
if (strstr($chunk[0], "--") !== false) {
|
if (strstr($chunks[0], "--") !== false) {
|
||||||
// EDGE
|
// EDGE
|
||||||
$graphviz_ids = explode("--", $chunk[0]);
|
$graphviz_ids = explode("--", $chunks[0]);
|
||||||
|
|
||||||
$edges[] = array(
|
$edges[] = array(
|
||||||
'to' => trim($graphviz_ids[0]),
|
'to' => trim($graphviz_ids[0]),
|
||||||
@ -80,21 +80,53 @@ class Networkmap extends Map {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// NODE
|
// NODE
|
||||||
$graphviz_id = trim($chunk[0]);
|
$graphviz_id = trim($chunks[0]);
|
||||||
|
|
||||||
if (strstr($chunk[1], "&id_module=") !== false) {
|
// Avoid the weird nodes.
|
||||||
|
if (!is_numeric($graphviz_id))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
$chunks = explode("ajax.php?", $chunks[1]);
|
||||||
|
|
||||||
|
if (strstr($chunks[1], "&id_module=") !== false) {
|
||||||
// MODULE
|
// MODULE
|
||||||
|
preg_match("/id_module=([0-9]*)/", $chunks[1], $matches);
|
||||||
|
$id = $matches[1];
|
||||||
|
$type = ITEM_TYPE_MODULE_NETWORKMAP;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// AGENT
|
// AGENT
|
||||||
|
preg_match("/id_agent=([0-9]*)/", $chunks[1], $matches);
|
||||||
|
$id = $matches[1];
|
||||||
|
$type = ITEM_TYPE_AGENT_NETWORKMAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$nodes[$graphviz_id] = array('id' => $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
html_debug($chunks, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($positions as $line) {
|
||||||
|
//clean line a long spaces for one space caracter
|
||||||
|
$line = preg_replace('/[ ]+/', ' ', $line);
|
||||||
|
|
||||||
|
if (preg_match('/^node.*$/', $line) != 0) {
|
||||||
|
$graphviz_id = $items[1];
|
||||||
|
|
||||||
|
$nodes[$graphviz_id]['x'] = $items[2] * 100; //200 is for show more big
|
||||||
|
$nodes[$graphviz_id]['y'] = $items[3] * 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($nodes as $graphviz_id => $node) {
|
||||||
|
$graph->$nodes[$graphviz_id] = $node;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($edges as $edge) {
|
||||||
|
$graph->nodes[] = array('type' => ITEM_TYPE_EDGE_NETWORKMAP);
|
||||||
|
$edge['id_item'] = key(end($graph->nodes[]));
|
||||||
|
$graph->edges[] = $edge;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function temp_parseParameters_generateDot() {
|
protected function temp_parseParameters_generateDot() {
|
||||||
@ -186,34 +218,19 @@ class Networkmap extends Map {
|
|||||||
|
|
||||||
system ($cmd);
|
system ($cmd);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$this->generateDot($graph, file($filename_plain));
|
||||||
|
|
||||||
unlink($filename_dot);
|
unlink($filename_dot);
|
||||||
|
unlink($filename_plain);
|
||||||
//~ html_debug($cmd);
|
|
||||||
//~ html_debug($filename_plain);
|
|
||||||
//~ html_debug(file_get_contents($filename_plain), true);
|
|
||||||
|
|
||||||
$this->generateDot($graph);
|
|
||||||
|
|
||||||
$nodes = networkmap_enterprise_loadfile($this->id,
|
|
||||||
$filename_plain,
|
|
||||||
$relation_nodes, $graph,
|
|
||||||
$parameters['l2_network_interfaces']);
|
|
||||||
//~ html_debug_print($graph);
|
|
||||||
//~ html_debug_print($nodes);
|
|
||||||
//~ html_debug_print($relation_nodes);
|
|
||||||
|
|
||||||
// debug image
|
|
||||||
// Read image path, convert to base64 encoding
|
|
||||||
$imgData = base64_encode(file_get_contents("/tmp/caca.png"));
|
|
||||||
|
|
||||||
// Format the image SRC: data:{mime};base64,{data};
|
|
||||||
$src = 'data: '.mime_content_type("/tmp/caca.png").';base64,'.$imgData;
|
|
||||||
|
|
||||||
// Echo out a sample image
|
|
||||||
echo '<img src="'.$src.'">';
|
|
||||||
|
|
||||||
// ----- END DEPRECATED CODE--------------------------------
|
// ----- END DEPRECATED CODE--------------------------------
|
||||||
$this->nodes[] = array(666);
|
|
||||||
|
switch (get_class($this)) {
|
||||||
|
case 'NetworkmapEnterprise':
|
||||||
|
NetworkmapEnterprise::dbSaveNodes();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,4 +489,9 @@ define("MOSAIC", 1);
|
|||||||
define("STRECH", 2);
|
define("STRECH", 2);
|
||||||
define("FIT_WIDTH", 3);
|
define("FIT_WIDTH", 3);
|
||||||
define("FIT_HEIGH", 4);
|
define("FIT_HEIGH", 4);
|
||||||
|
|
||||||
|
/* Items of maps */
|
||||||
|
define("ITEM_TYPE_AGENT_NETWORKMAP", 0);
|
||||||
|
define("ITEM_TYPE_MODULE_NETWORKMAP", 1);
|
||||||
|
define("ITEM_TYPE_EDGE_NETWORKMAP", 2);
|
||||||
?>
|
?>
|
||||||
|
@ -21,10 +21,4 @@
|
|||||||
* @subpackage Networkmaps
|
* @subpackage Networkmaps
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function networkmaps_show($id) {
|
|
||||||
maps_show($id);
|
|
||||||
|
|
||||||
networkmaps_show_staged_area($id);
|
|
||||||
networkmaps_show_black_list_staged_area($id);
|
|
||||||
}
|
|
||||||
?>
|
?>
|
@ -141,8 +141,7 @@ else {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
html_debug(file_get_contents("/tmp/caca.txt"), true);
|
|
||||||
html_debug($graph);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user