This repository has been archived by the owner on Jun 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstats.php
155 lines (139 loc) · 3.54 KB
/
stats.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/**
* Stats file
*
* @package mpv_server
* @version $Id$
* @copyright (c) 2010 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n");
$phpEx = substr(strrchr(__FILE__, '.'), 1);
$root_path = './';
// Will define all needed things.
include($root_path . 'mpv_config.' . $phpEx);
include($root_path . 'includes/languages/' . MPV_LANG . '/lang.' . $phpEx);
include($root_path . 'includes/functions_mpv.' . $phpEx);
include($root_path . 'includes/mpv.' . $phpEx);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb">
<head>
<style type="text/css">
table.data {
border-width: 1px;
border-spacing: 2px;
border-style: outset;
border-color: gray;
border-collapse: separate;
background-color: white;
margin: 0 auto;
}
table.data th {
border-width: 1px;
padding: 1px;
border-style: inset;
border-color: gray;
background-color: lightgray;
}
table.data td {
border-width: 1px;
padding: 5px;
border-style: inset;
border-color: gray;
background-color: white;
}
</style>
<title><?php print $lang['TITLE_STATS']; ?></title>
</head>
<body>
<br /><br />
<?php
//Do we need to show some statistics?
if (sizeof($statistics))
{
$mod_count = $property_count = $entries = $split_entry = $entries_values = array();
foreach ($statistics as $tag => $properties)
{
$data_file = './store/data/' . $tag . '_data.txt';
if (file_exists($data_file))
{
$contents = file_get_contents($data_file);
$entries = explode("\r\n", $contents);
foreach ($entries as $entry)
{
$mod_name = '';
$split_entry = explode("||", $entry);
foreach ($split_entry as $entry_value)
{
//Check for the MOD name and assign counts as needed
if (empty($mod_name))
{
$mod_name = $entry_value;
$mod_name_id = str_replace(' ', '_', $mod_name);
if (isset($mod_count[$mod_name_id]))
{
$mod_count[$mod_name_id] += 1;
}
else
{
$mod_count = array_merge($mod_count, array($mod_name_id => 1));
}
$entries_values[] = $entry_value;
continue;
}
$entries_values[] = $entry_value;
$entry_value_id = str_replace(' ', '_', $entry_value);
if (isset($property_count[$entry_value_id]))
{
$property_count[$entry_value_id] += 1;
}
else
{
$property_count = array_merge($property_count, array($entry_value_id => 1));
}
}
}
}
}
//Remove the duplicates
$entries_values = array_unique($entries_values);
sort($entries_values);
$row = " <tr><td>%s</td><td style=\"text-align:right;\">%s</td></tr>\n";
print '<table id="tag_data" class="data">
<tr>
<th>' . $lang['TAG_DATA'] . '</th><th>' . $lang['DATA_COUNT'] . "</th>
</tr>\n";
//Print out each row for the properties
foreach ($entries_values as $entry)
{
$entry_id = str_replace(' ', '_', $entry);
if (isset($property_count[$entry_id]))
{
print sprintf($row, $entry, $property_count[$entry_id]);
}
}
print '</table>
<br /><br />
<table id="mod_names" class="data">
<tr>
<th>' . $lang['MOD_NAME'] . '</th><th>' . $lang['SUBMIT_COUNT'] . "</th>
</tr>\n";
//Print out each row for the MOD names
foreach ($entries_values as $entry)
{
if (!empty($entry))
{
$entry_id = str_replace(' ', '_', $entry);
if (isset($mod_count[$entry_id]))
{
print sprintf($row, $entry, $mod_count[$entry_id]);
}
}
}
print '</table>';
}
?>
</body>
</html>