/** * Returns GraphViz/dot markup for the graph. * * @param boolean $returnObject * @return mixed * @access public */ function toGraph($returnObject = false) { if (!@(include_once 'Image/GraphViz.php')) { phpOpenTracker::handleError('Could not find PEAR Image_GraphViz package, exiting.', E_USER_ERROR); } $graph = new Image_GraphViz(); for ($i = 0; $i < $this->length - 1; $i++) { $graph->addNode($i, array('url' => $this->document_urls[$i], 'label' => $this->documents[$i], 'shape' => 'box')); $graph->addNode($i + 1, array('url' => $this->document_urls[$i + 1], 'label' => $this->documents[$i + 1], 'shape' => 'box')); if (isset($this->statistics[$i]['count'])) { $label = sprintf('count: %d\\naverage time: %d seconds', $this->statistics[$i]['count'], $this->statistics[$i]['time_spent']); } else { $label = sprintf('time spent: %d seconds', $this->statistics[$i]); } $graph->addEdge(array($i => $i + 1), array('label' => $label)); } if ($returnObject) { return $graph; } else { return $graph->parse(); } }
/** * Flush buffer and close output. * * @access public */ public function flush() { $this->write($this->graph->parse()); parent::flush(); }
$as_e_tmp = "AS" . $as; $as_info_dns = dns_get_record($as_e_tmp . ".asn.cymru.com", DNS_TXT); list($as_info['as'], $as_info['country'], $as_info['rir'], $as_info['date'], $as_info['desc']) = explode("|", $as_info_dns[0]['txt']); $asinfo = explode(" ", $as_info['desc']); $as_e = $as_e_tmp . " " . $asinfo[1]; $gv->addEdge(array($as_s => $as_e)); $as_s = $as_e; } } } } } mysqli_close($mid); switch ($gixlg['graphviz_mode']) { // Direct function call case "direct": $gv->image('jpg'); break; // Executing dot parser from cmd line // Executing dot parser from cmd line case "cmd": $dot = $gv->parse(); header("Content-type: image/jpg"); passthru("echo '{$dot}' | /usr/local/bin/dot -Tjpg"); break; case "cmd_svg": $dot = $gv->parse(); header("Content-type: image/svg+xml"); passthru("echo '{$dot}' | /usr/local/bin/dot -Tsvg"); break; }