ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
showstats.php
Go to the documentation of this file.
1 <?php
2 
6 
8 
9 /*
10  * Check input parameters
11  */
12 $preferRule = null;
13 $preferRule2 = null;
14 $preferTime = null;
16 $delimiter = null;
17 
18 if (array_key_exists('rule', $_REQUEST)) {
19  $preferRule = $_REQUEST['rule'];
20 }
21 if (array_key_exists('rule2', $_REQUEST)) {
22  $preferRule2 = $_REQUEST['rule2'];
23 }
24 if (array_key_exists('time', $_REQUEST)) {
25  $preferTime = $_REQUEST['time'];
26 }
27 if (array_key_exists('res', $_REQUEST)) {
28  $preferTimeRes = $_REQUEST['res'];
29 }
30 if (array_key_exists('d', $_REQUEST)) {
31  $delimiter = $_REQUEST['d'];
32 }
33 
34 if ($preferRule2 === '_') {
35  $preferRule2 = null;
36 }
37 
38 /*
39  * Create statistics data.
40  */
43 $rule = $statrule->getRuleID();
44 
46 $dataset->setDelimiter($delimiter);
47 
48 $delimiter = $dataset->getDelimiter();
49 
50 $timeres = $dataset->getTimeRes();
51 $fileslot = $dataset->getFileslot();
52 $availableFileSlots = $statrule->availableFileSlots($timeres);
53 
55 
56 $dataset->aggregateSummary();
57 $dataset->calculateMax();
58 
59 $piedata = $dataset->getPieData();
60 
62 $datasets[] = $dataset->getPercentValues();
63 
64 $axis = $dataset->getAxis();
65 
67 
68 $maxes[] = $dataset->getMax();
69 
70 if (isset($preferRule2)) {
71  $statrule = $ruleset->getRule($preferRule2);
72  $dataset2 = $statrule->getDataset($preferTimeRes, $preferTime);
73  $dataset2->aggregateSummary();
74  $dataset2->calculateMax();
75 
76  $datasets[] = $dataset2->getPercentValues();
77  $maxes[] = $dataset2->getMax();
78 }
79 
80 $dimx = $statconfig->getValue('dimension.x', 800);
81 $dimy = $statconfig->getValue('dimension.y', 350);
83 
84 if (array_key_exists('output', $_REQUEST) && $_REQUEST['output'] === 'csv') {
85  header('Content-type: text/csv');
86  header('Content-Disposition: attachment; filename="simplesamlphp-data.csv"');
87  $data = $dataset->getDebugData();
88  foreach ($data as $de) {
89  if (isset($de[1])) {
90  echo '"' . $de[0] . '",' . $de[1] . "\n";
91  }
92  }
93  exit;
94 }
95 
96 $t = new SimpleSAML_XHTML_Template($config, 'statistics:statistics.tpl.php');
97 $t->data['pageid'] = 'statistics';
98 $t->data['header'] = 'stat';
99 $t->data['imgurl'] = $grapher->show($axis['axis'], $axis['axispos'], $datasets, $maxes);
100 if (isset($piedata)) {
101  $t->data['pieimgurl'] = $grapher->showPie( $dataset->getDelimiterPresentationPie(), $piedata);
102 }
103 $t->data['available.rules'] = $ruleset->availableRulesNames();
104 $t->data['available.times'] = $statrule->availableFileSlots($timeres);
105 $t->data['available.timeres'] = $statrule->availableTimeRes();
106 $t->data['available.times.prev'] = $timeNavigation['prev'];
107 $t->data['available.times.next'] = $timeNavigation['next'];
108 
109 $t->data['selected.rule']= $rule;
110 $t->data['selected.rule2']= $preferRule2;
111 $t->data['selected.time'] = $fileslot;
112 $t->data['selected.timeres'] = $timeres;
113 $t->data['selected.delimiter'] = $delimiter;
114 
115 $t->data['debugdata'] = $dataset->getDebugData();
116 $t->data['results'] = $dataset->getResults();
117 $t->data['summaryDataset'] = $dataset->getSummary();
118 $t->data['topdelimiters'] = $dataset->getTopDelimiters();
119 $t->data['availdelimiters'] = $dataset->availDelimiters();
120 
121 $t->data['delimiterPresentation'] = $dataset->getDelimiterPresentation();
122 
123 $t->data['post_rule'] = getBaseURL($t, 'post', 'rule');
124 $t->data['post_rule2'] = getBaseURL($t, 'post', 'rule2');
125 $t->data['post_d'] = getBaseURL($t, 'post', 'd');
126 $t->data['post_res'] = getBaseURL($t, 'post', 'res');
127 $t->data['post_time'] = getBaseURL($t, 'post', 'time');
128 $t->data['get_times_prev'] = getBaseURL($t, 'get', 'time', $t->data['available.times.prev']);
129 $t->data['get_times_next'] = getBaseURL($t, 'get', 'time', $t->data['available.times.next']);
130 
131 $t->show();
132 
133 function getBaseURL($t, $type = 'get', $key = null, $value = null)
134 {
135  $vars = array(
136  'rule' => $t->data['selected.rule'],
137  'time' => $t->data['selected.time'],
138  'res' => $t->data['selected.timeres'],
139  );
140  if (isset($t->data['selected.delimiter'])) {
141  $vars['d'] = $t->data['selected.delimiter'];
142  }
143  if (!empty($t->data['selected.rule2']) && $t->data['selected.rule2'] !== '_') {
144  $vars['rule2'] = $t->data['selected.rule2'];
145  }
146 
147  if (isset($key)) {
148  if (isset($vars[$key])) {
149  unset($vars[$key]);
150  }
151  if (isset($value)) {
152  $vars[$key] = $value;
153  }
154  }
155 
156  if ($type === 'get') {
157  return SimpleSAML\Module::getModuleURL("statistics/showstats.php") . '?' . http_build_query($vars, '', '&amp;');
158  } else {
159  $text = '';
160  foreach($vars as $k => $v) {
161  $text .= '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n";
162  }
163  return $text;
164  }
165 }
$availableFileSlots
Definition: showstats.php:52
$preferRule2
Definition: showstats.php:13
$piedata
Definition: showstats.php:59
$config
Definition: showstats.php:3
if(isset($preferRule2)) $dimx
Definition: showstats.php:80
$session
Definition: showstats.php:5
$type
if(array_key_exists('rule', $_REQUEST)) if(array_key_exists('rule2', $_REQUEST)) if(array_key_exists('time', $_REQUEST)) if(array_key_exists('res', $_REQUEST)) if(array_key_exists('d', $_REQUEST)) if($preferRule2==='_') $ruleset
Definition: showstats.php:41
$fileslot
Definition: showstats.php:51
$delimiter
Definition: showstats.php:16
$dataset
Definition: showstats.php:45
$statconfig
Definition: showstats.php:4
$dimy
Definition: showstats.php:81
$timeres
Definition: showstats.php:50
$timeNavigation
Definition: showstats.php:54
static checkAccess(SimpleSAML_Configuration $statconfig)
Check that the user has access to the statistics.
Definition: AccessCheck.php:15
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:303
$preferRule
Definition: showstats.php:12
$datasets
Definition: showstats.php:61
$rule
Definition: showstats.php:43
getBaseURL($t, $type='get', $key=null, $value=null)
Definition: showstats.php:133
$preferTimeRes
Definition: showstats.php:15
$text
Definition: errorreport.php:18
static getConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
Add a drawing to the header
Definition: 04printing.php:69
$statrule
Definition: showstats.php:42
Create styles array
The data for the language used.
if(array_key_exists('output', $_REQUEST) && $_REQUEST['output']==='csv') $t
Definition: showstats.php:96
$preferTime
Definition: showstats.php:14
$grapher
Definition: showstats.php:82
$axis
Definition: showstats.php:64
$maxes
Definition: showstats.php:66
$key
Definition: croninfo.php:18
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:243
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.