Mercurial > hg > freeDiameter
annotate contrib/app_acct_tools/display_stats.php @ 533:4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Tue, 07 Sep 2010 16:57:48 +0900 |
parents | |
children |
rev | line source |
---|---|
533
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 <?php |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 # The copyright of this file is the same as the freeDiameter project. Licence is BSD. |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
5 #------------------------------------------------------------------------------------------ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 # DATABASE: |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
8 /* The Connection String used to access that database: |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 Example: "host=localhost dbname=app_acct user=freediameter password=foo" */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 $CONNSTR=""; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 /* The name of the table containing the processed data (from process_records.php script) */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 $PROCESSED="processed"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 #------------------------------------------------------------------------------------------ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 ?> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 <html lang="en-US"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 <head> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 <title>Accounting Data</title> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 <meta name="description" content="This page gives you access to your personal accounting data."> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 <meta name="keywords" content="accounting"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
26 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
27 <style type="text/css"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
28 body { text-align:center; } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 table.colored { border-collapse:collapse; margin-left:auto; margin-right:auto; } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
30 table.colored td, table.colored th { border:1px solid green; padding-left:.5em; padding-right:.5em;} |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
31 .colored th { background-color:green; color:white; } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
32 hr { width:15px; margin-top:2em;margin-bottom:2em; } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 </style> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 </head> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 <body > |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 <h1>Statistical accounting data</h1> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 <form method="GET"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 <table class="colored"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 <tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 <th colspan="3"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 Filtering options |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
43 </th> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
44 </tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
45 <tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
46 <td><input type="checkbox" name="c_starttime"<?php if (isset($_GET["c_starttime"])) echo " checked"; ?>></td> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
47 <td>Limit to sessions starting from (<a href="http://www.postgresql.org/docs/8.4/static/datatype-datetime.html">hint</a>):</td> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
48 <td><input type="text" title="YYYY-MM-DD HH:MM:SS" name="t_starttime"<?php if (isset($_GET["t_starttime"])) echo 'value="'.$_GET["t_starttime"].'"'; ?>></td> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
49 </tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 <tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 <td><input type="checkbox" name="c_endtime"<?php if (isset($_GET["c_endtime"])) echo " checked"; ?>></td> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
52 <td>Limit to sessions starting until (<a href="http://www.postgresql.org/docs/8.4/static/datatype-datetime.html">hint</a>):</td> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
53 <td><input type="text" title="YYYY-MM-DD HH:MM:SS" name="t_endtime"<?php if (isset($_GET["t_endtime"])) echo 'value="'.$_GET["t_endtime"].'"'; ?>></td> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
54 </tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 <tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
56 <th colspan="3"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
57 Apply this filter: <input type="submit" name="Submit"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
58 </th> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
59 </tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
60 </table> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
61 </form> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
62 <p>Note well: this page displays only data about <em>terminated</em> sessions.</p> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 <?php |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
64 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
65 /* Connect to the database */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 $dbconn = pg_connect($CONNSTR) |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
67 or die('Could not connect: ' . pg_last_error() . "\n"); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
68 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
69 if ($_GET["c_starttime"] && $_GET["t_starttime"]) { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
70 $START_TIME=$_GET["t_starttime"]; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
71 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
72 if ($_GET["c_endtime"] && $_GET["t_endtime"]) { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
73 $END_TIME=$_GET["t_endtime"]; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
74 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
75 $sql_cond=""; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
76 if ($START_TIME) { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
77 $sql_cond = "sess_start >= '".pg_escape_string($START_TIME)."'"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
78 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
79 if ($END_TIME) { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
80 if ($sql_cond) |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
81 $sql_cond .= " AND "; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
82 $sql_cond .= "sess_start =< '".pg_escape_string($END_TIME)."'"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
83 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
84 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
85 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
86 /* Function to format download size (from php.net) */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
87 function human_readable( $size ) |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
88 { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
89 $count = 0; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
90 $format = array("B","KB","MB","GB","TB","PB","EB","ZB","YB"); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
91 while(($size/1024)>1 && $count<8) |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
92 { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
93 $size=$size/1024; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
94 $count++; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
95 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
96 if( $size >= 100 ) $decimals = 0; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
97 elseif ($size >= 10 ) $decimals = 1; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
98 else $decimals = 2; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
99 $return = number_format($size,$decimals,'.',' ')." ".$format[$count]; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
100 return $return; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
101 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
102 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
103 ?> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
104 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
105 <hr /> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
106 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
107 <?php |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
108 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
109 /* First query: global data */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
110 $sql = 'SELECT SUM(downl_bytes) as total_down, SUM(upl_bytes) as total_up,'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
111 $sql .= ' to_char(min(sess_start), \'YYYY-MM-DD HH24:MI:SS TZ\') as first_sess,'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
112 $sql .= ' to_char(max(sess_start), \'YYYY-MM-DD HH24:MI:SS TZ\') as last_sess,'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
113 $sql .= ' count(distinct user_name) as nb_users,'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
114 $sql .= ' count(distinct nas_info) as nb_ap'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
115 $sql .= ' FROM "'.$PROCESSED.'"'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
116 if ($sql_cond) |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
117 $sql .= ' WHERE '.$sql_cond; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
118 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
119 /* Execute the query */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
120 $result = pg_query($dbconn, $sql) or die('Query failed: ' . pg_last_error() . "\n"); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
121 if (pg_num_rows($result) == 0) { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
122 echo "<p><em>No data is available in the selected period.</em></p>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
123 die("</body></html>\n"); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
124 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
125 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
126 $data = pg_fetch_array($result, null, PGSQL_ASSOC); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
127 ?> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
128 <table class="colored"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
129 <tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
130 <th colspan="2">Total accounted data</th> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
131 </tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
132 <?php |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
133 echo " <tr><td>First session started:</td><td>".$data["first_sess"]."</td></tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
134 echo " <tr><td>Last session started:</td><td>".$data["last_sess"]."</td></tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
135 echo " <tr><td>Total data downloaded:</td><td><strong>".human_readable($data["total_down"])."</strong></td></tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
136 echo " <tr><td>Total data uploaded:</td><td><strong>".human_readable($data["total_up"])."</strong></td></tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
137 echo " <tr><td>Number of users who connected at least once:</td><td>".$data["nb_users"]."</td></tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
138 echo " <tr><td>Number of access points involved:</td><td>".$data["nb_ap"]."</td></tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
139 echo " </tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
140 echo " </table>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
141 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
142 pg_free_result($result); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
143 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
144 ?> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
145 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
146 <hr /> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
147 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
148 <table class="colored"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
149 <tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
150 <th colspan="2">Top-5 <strong>downloading</strong> users</th> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
151 </tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
152 <?php |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
153 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
154 /* Now, get the top 5 downloaders */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
155 $sql = 'SELECT SUM(downl_bytes) as total_down, user_name'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
156 $sql .= ' FROM "'.$PROCESSED.'"'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
157 if ($sql_cond) |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
158 $sql .= ' WHERE '.$sql_cond; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
159 $sql .= ' GROUP BY user_name'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
160 $sql .= ' ORDER BY total_down desc, user_name'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
161 $sql .= ' LIMIT 5'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
162 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
163 /* Execute the query */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
164 $result = pg_query($dbconn, $sql) or die('Query failed: ' . pg_last_error() . "\n"); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
165 while ($data = pg_fetch_array($result, null, PGSQL_ASSOC)) { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
166 echo " <tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
167 echo " <td>".htmlentities(pg_unescape_bytea($data["user_name"]))."</td>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
168 echo " <td>".human_readable($data["total_down"])."</td>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
169 echo " </tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
170 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
171 pg_free_result($result); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
172 ?> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
173 </table> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
174 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
175 <hr /> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
176 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
177 <table class="colored"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
178 <tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
179 <th colspan="2">Top-5 <strong>uploading</strong> users</th> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
180 </tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
181 <?php |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
182 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
183 /* Now, get the top 5 downloaders */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
184 $sql = 'SELECT SUM(upl_bytes) as total_up, user_name'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
185 $sql .= ' FROM "'.$PROCESSED.'"'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
186 if ($sql_cond) |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
187 $sql .= ' WHERE '.$sql_cond; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
188 $sql .= ' GROUP BY user_name'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
189 $sql .= ' ORDER BY total_up desc, user_name'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
190 $sql .= ' LIMIT 5'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
191 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
192 /* Execute the query */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
193 $result = pg_query($dbconn, $sql) or die('Query failed: ' . pg_last_error() . "\n"); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
194 while ($data = pg_fetch_array($result, null, PGSQL_ASSOC)) { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
195 echo " <tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
196 echo " <td>".htmlentities(pg_unescape_bytea($data["user_name"]))."</td>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
197 echo " <td>".human_readable($data["total_up"])."</td>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
198 echo " </tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
199 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
200 pg_free_result($result); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
201 ?> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
202 </table> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
203 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
204 <hr /> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
205 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
206 <table class="colored"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
207 <tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
208 <th colspan="2">Top-8 access devices (by number of users)</th> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
209 </tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
210 <?php |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
211 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
212 /* Now, get the top 5 downloaders */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
213 $sql = 'SELECT count(distinct user_name) as unc, nas_info'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
214 $sql .= ' FROM "'.$PROCESSED.'"'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
215 if ($sql_cond) |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
216 $sql .= ' WHERE '.$sql_cond; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
217 $sql .= ' GROUP BY nas_info'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
218 $sql .= ' ORDER BY unc desc, nas_info'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
219 $sql .= ' LIMIT 8'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
220 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
221 /* Execute the query */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
222 $result = pg_query($dbconn, $sql) or die('Query failed: ' . pg_last_error() . "\n"); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
223 while ($data = pg_fetch_array($result, null, PGSQL_ASSOC)) { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
224 echo " <tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
225 echo " <td>".htmlentities(pg_unescape_bytea($data["nas_info"]))."</td>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
226 echo " <td>".$data["unc"]."</td>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
227 echo " </tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
228 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
229 pg_free_result($result); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
230 ?> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
231 </table> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
232 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
233 <hr /> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
234 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
235 <table class="colored"> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
236 <tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
237 <th colspan="2">Top-8 access devices (by traffic: up+down)</th> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
238 </tr> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
239 <?php |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
240 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
241 /* Now, get the top 5 downloaders */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
242 $sql = 'SELECT SUM(upl_bytes) + SUM(downl_bytes) as traffic, nas_info'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
243 $sql .= ' FROM "'.$PROCESSED.'"'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
244 if ($sql_cond) |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
245 $sql .= ' WHERE '.$sql_cond; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
246 $sql .= ' GROUP BY nas_info'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
247 $sql .= ' ORDER BY traffic desc, nas_info'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
248 $sql .= ' LIMIT 8'; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
249 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
250 /* Execute the query */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
251 $result = pg_query($dbconn, $sql) or die('Query failed: ' . pg_last_error() . "\n"); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
252 while ($data = pg_fetch_array($result, null, PGSQL_ASSOC)) { |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
253 echo " <tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
254 echo " <td>".htmlentities(pg_unescape_bytea($data["nas_info"]))."</td>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
255 echo " <td>".human_readable($data["traffic"])."</td>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
256 echo " </tr>\n"; |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
257 } |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
258 pg_free_result($result); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
259 ?> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
260 </table> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
261 |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
262 <hr /> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
263 <?php |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
264 /* Closing connection */ |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
265 pg_close($dbconn); |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
266 ?> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
267 <p><small>Data generated by scripts from the <a href="http://www.freediameter.net">freeDiameter</a> project.</small></p> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
268 </body> |
4cdf146f11d5
Added a set of example PHP scripts to parse the app_acct.fdx data.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
269 </html> |