/
dl_statistics_display.php
107 lines (78 loc) · 2.54 KB
/
dl_statistics_display.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/******* Display download - statistics *****
VERSION 0.1 - Matthias Strubel (c) 2013 - GPL3
Very simple script to get access to the statistic data.
Following GET-Options are possible:
sortOrder = ASC / DESC - Ascendening or decsending sort order
sortBy = url/counter Sort by complete "url" to file, or based on download "counter"
list_type = "all" display all data ; "top" - limit display with top n entries
top_max = The maximum number of values to return in "top" mode.
output_type = none or html results in a simple html output
"json" results in a json structure
Default values are provided by dl_statistics.conf.php.
The HTML output is based on a file pointed in "dl_statistics.conf.php" to.
That file lays on librarybox in the content folder
http://librarybox.us/content/....
which is in reality on the USB stick. That file can simply exchanged without the need
of touching the logic behind.
Currently I don't have the path filter programmed in that script.
CHANGELOG:
0.1 RELEASE
********************************************/
require_once "dl_statistics.conf.php";
include "dl_statistics.func.php";
$config=dl_get_config();
$sort=$config["sortOrder"];
$sortBy=$config["sortBy"];
$top_max=$config["top_max"];
$output_type=$config["output_type"];
$list_type=$config["list_type"];
if ( isset ($_GET['sortOrder'] )) {
if ( $_GET['sortOrder'] == 'ASC' ) {
$sort='ASC';
} else {
$sort='DESC';
}
}
if ( isset ($_GET['sortBy']) ) {
if ( $_GET["sortBy"] == "url" ) {
$sortBy="url";
} elseif ( $_GET["sortBy"] == "counter" ) {
$sortBy="counter";
}
}
if ( isset ($_GET['top_max'] )) {
$top_max = $_GET['top_max'];
}
if ( isset ($_GET['output_type'] )) {
if ( $_GET["output_type"] == "json" ) {
$output_type= "json";
} elseif ( $_GET["output_type"] == "html" ) {
$output_type="html";
}
}
if ( isset ( $_GET['list_type'] )) {
$list_type= $_GET['list_type'];
}
#----------------------------------
# Detect which statement
$result = dl_read_stat_per_path ( '%' , $sortBy , $sort , $list_type , $top_max );
#------------------------------------------------
# Output
if ( is_array ( $result ) ) {
if ( $output_type == "html" ) {
# Template file for HTML output
include $config["HTML_TEMPLATE_FILE"];
output_html ( $result, array (
'list_type' => $list_type,
'top_max' => $top_max ,
"sortBy" => $sortBy ,
"sortOrder" => $sort,
"filter_path" => false ,
));
} elseif ( $output_type == "json" ) {
header('Content-Type: application/json');
print json_encode ( $result );
}
}
?>