ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

report_run.inc.php
Go to the documentation of this file.
1 <?php
8 function report_run($options="") {
9  global $conf, $self, $onadb, $base;
10 
11  // Version - UPDATE on every edit!
12  $version = '1.01';
13 
14  printmsg("DEBUG => report_run({$options}) called", 3);
15 
16  // Parse incoming options string to an array
17  $options = parse_options($options);
18 
19  // Return the usage summary if we need to
20  if ($options['help'] or !(($options['list'] and !$options['name']) or (!$options['list'] and $options['name']))) {
21  // NOTE: Help message lines should not exceed 80 characters for proper display on a console
22  $self['error'] = 'ERROR => Insufficient parameters';
23  return(array(1,
24 <<<EOM
25 
27 Run a report
28 
29  Synopsis: report_run [KEY=VALUE] ...
30 
31  Required:
32  name=NAME The name of the report to run
33  OR
34  list List the available report names
35 
36  Optional:
37  rpt_usage Print a usage message for the specified report
38  format=FORMAT The name of the ouput format of the report (default: text)
39 
40 EXAMPLE:
41  dcm.pl -r report_run name=nmap_scan subnet=10.1.40.0 format=text <- run with text output.
42  dcm.pl -r report_run name=nmap_scan rpt_usage <- Print usage info for nmap_scan report.
43 
44 EOM
45  ));
46  }
47 
48  $status=0;
49 
50 
51 
52  // Generate a list of reports available
53  if ($options['list'] == 'Y') {
54  $text .= sprintf("\n%-25s\n",'Report Name');
55  $text .= sprintf("%'-80s\n",'');
56  $files = array();
57 
58  // Get the description info for the report items
59  $reportlist = plugin_list('report_item');
60 
61  // sort the file names
62  asort($reportlist);
63 
64  // Loop through the list of reports and show its name and description
65  foreach ($reportlist as $entry) {
67  $record['name'] = $entry['name'];
68  $record['shortname'] = str_replace('.inc.php', '', $record['name']);
69  include_once $entry['path'];
70  $record['desc'] = $report_description;
71 
72  $text .= sprintf("%-35s %s\n",$record['shortname'], $record['desc']);
73  }
74 
75  return(array(0, $text));
76  }
77 
78  // default format will be text for the cli stuff
79  if (!$options['format']) $options['format'] = 'text';
80 
81  // Get the actual report code list
82  $reports = plugin_list('report');
83 
84  // Loop through the list of reports till we find the matching name
85  foreach($reports as $report) {
86  if ($report['name'] == $options['name']) {
87  // Load the report include file
88  if (require_once($report['path'])) {
89  // Run the report and return the output
90  list($status, $report_output) = rpt_run($options, $options['format']);
91  }
92  }
93  }
94 
95  $text = $report_output;
96 
97  // Return the success notice
98  return(array($status , $text."\n"));
99 
100 
101 
102 }
103 
104 
105 ?>
$reports
$reports
Definition: main.inc.php:26
$record
$record['display_name']
Definition: app_advanced_search.inc.php:12
$status
$status
Definition: install.php:12
$onadb
global $onadb
Definition: 2-to-3.php:15
rpt_run
rpt_run($form, $output_format='html')
Definition: report.inc.php:18
printmsg
if(6<=$conf['debug']) printmsg($msg="", $debugLevel=0)
Definition: functions_general.inc.php:48
report_run
report_run($options="")
Definition: report_run.inc.php:8
$report_description
$report_description
Definition: report_item.inc.php:5
$conf
global $conf
Definition: 2-to-3.php:15
$text
$text
Definition: install.php:11
$self
global $self
Definition: 2-to-3.php:15
$base
$base
Definition: 2-to-3.php:8
parse_options
parse_options($options="")
Definition: functions_general.inc.php:1579
$version
$version
Definition: main.inc.php:22
plugin_list
plugin_list($type='')
Definition: functions_gui.inc.php:62