-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
54 lines (41 loc) · 1.32 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @author Julian Bogdani <jbogdani@gmail.com>
* @copyright BraDypUS 2007-2013
* @license All rights reserved
* @since Apr 23, 2013
*/
use graphviz\phpGraphviz;
try
{
/**
* System settings
*/
$graphviz_path = '/usr/local/bin/';
/**
* URL paramaters settings
*/
// dot_url: string, required, full URL to dot file.
if (!$_GET['dot_url'])
{
throw new Exception('No path to dot file found!');
}
// dot_url is the full url to the DOT file to process
$dot_url = $_GET['dot_url'];
// format: string, optional, output file format (png, gif, jpeg, svg). Default value: png.
$_GET['format'] ? $format = strtolower($_GET['format']) : '';
// graph_type: string, optional, output graph type (directed, undirected, readial, circular, fdp, sfdb). Default vale: directed.
$_GET['graph_type'] ? $graph_type = strtolower($_GET['graph_type']) : '';
// dont_clean: boolean, optinal. if true the transitive reduction filter for directed graphs will not be applied
$clean = $_GET['dont_clean'] ? false : true;
// include class
require_once 'phpGraphviz.php';
// initialize object
$graphviz = new graphviz\phpGraphviz($graphviz_path);
$graphviz->getGraph($dot_url, $clean, $format, $graph_type);
}
// catch errors
catch (Exception $e)
{ // echo error message
echo "Error: " . $e->getMessage();
}