Merge branch 'bug-1394' into testserver-stable
[cacert-devel.git] / www / stats.php
1 <? /*
2 LibreSSL - CAcert web application
3 Copyright (C) 2004-2008 CAcert Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 loadem("index");
20 showheader(_("Welcome to CAcert.org"));
21
22 /**
23 * get statistics data from current cache, return result of getDataFromLive if no cache file exists
24 * @return array
25 */
26 function getData() {
27 $sql = 'select * from `statscache` order by `timestamp` desc limit 1';
28 $res = mysql_query($sql);
29 if ($res && mysql_numrows($res) > 0) {
30 $ar = mysql_fetch_assoc($res);
31 $stats = unserialize($ar['cache']);
32 $stats['timestamp'] = $ar['timestamp'];
33 return $stats;
34 }
35
36 return null;
37 }
38
39 $stats = getData();
40 if ($stats === null) {
41 echo '<p>', _("Error while retrieving the statistics!"), '</p>';
42 showfooter();
43 die();
44 }
45 ?>
46 <h1>CAcert.org <?=_("Statistics")?></h1>
47
48 <table align="center" border="0" cellspacing="0" cellpadding="0" class="wrapper">
49 <tr>
50 <td colspan="2" class="title">CAcert.org <?=_("Statistics")?></td>
51 </tr>
52 <tr>
53 <td class="DataTD"><?=_("Verified Users")?>:</td>
54 <td class="DataTD"><?=$stats['verified_users'];?></td>
55 </tr>
56 <tr>
57 <td class="DataTD"><?=_("Verified Emails")?>:</td>
58 <td class="DataTD"><?=$stats['verified_emails'];?></td>
59 </tr>
60 <tr>
61 <td class="DataTD"><?=_("Verified Domains")?>:</td>
62 <td class="DataTD"><?=$stats['verified_domains'];?></td>
63 </tr>
64 <tr>
65 <td class="DataTD"><?=_("Certificates Issued")?>:</td>
66 <td class="DataTD"><?=$stats['verified_certificates'];?></td>
67 </tr>
68 <tr>
69 <td class="DataTD"><?=_("Valid Certificates")?>:</td>
70 <td class="DataTD"><?=$stats['valid_certificates'];?></td>
71 </tr>
72 <tr>
73 <td class="DataTD"><?=_("Assurances Made")?>:</td>
74 <td class="DataTD"><?=$stats['assurances_made'];?></td>
75 </tr>
76 <tr>
77 <td class="DataTD"><?=_("Users with 1-49 Points")?>:</td>
78 <td class="DataTD"><?=$stats['users_1to49'];?></td>
79 </tr>
80 <tr>
81 <td class="DataTD"><?=_("Users with 50-99 Points")?>:</td>
82 <td class="DataTD"><?=$stats['users_50to99'];?></td>
83 </tr>
84 <tr>
85 <td class="DataTD"><?=_("Assurer Candidates")?>:</td>
86 <td class="DataTD"><?=$stats['assurer_candidates'];?></td>
87 </tr>
88 <tr>
89 <td class="DataTD"><?=_("Assurers with test")?>:</td>
90 <td class="DataTD"><?=$stats['assurer_with_test'];?></td>
91 </tr>
92 <tr>
93 <td class="DataTD"><?=_("Points Issued")?>:</td>
94 <td class="DataTD"><?=$stats['points_issued'];?></td>
95 </tr>
96 </table>
97 <br>
98 <table align="center" border="0" cellspacing="0" cellpadding="0" class="wrapper">
99 <tr>
100 <td colspan="4" class="title">CAcert.org <?=_("Growth in the last 12 months")?></td>
101 </tr>
102 <tr>
103 <td class="DataTD"><b><?=_("Date")?></b>
104 <td class="DataTD"><b><?=_("New Users")?></b>
105 <td class="DataTD"><b><?=_("New Assurers") . ' *'?></b>
106 <td class="DataTD"><b><?=_("New Certificates")?></b>
107 </tr>
108 <?
109 for($i = 0; $i < 12; $i++) {
110 ?>
111 <tr>
112 <td class="DataTD"><?=$stats['growth_last_12m'][$i]['date'];?></td>
113 <td class="DataTD"><?=$stats['growth_last_12m'][$i]['new_users'];?></td>
114 <td class="DataTD"><?= $stats['growth_last_12m'][$i]['new_candidates'] . '/' . $stats['growth_last_12m'][$i]['new_assurers'];?></td>
115 <td class="DataTD"><?=$stats['growth_last_12m'][$i]['new_certificates'];?></td>
116 </tr>
117 <? } ?>
118 <tr>
119 <td class="DataTD"><?=_("Total")?></td>
120 <td class="DataTD"><?=$stats['growth_last_12m_total']['new_users'];?></td>
121 <td class="DataTD"><?=$stats['growth_last_12m_total']['new_candidates'] . '/' . $stats['growth_last_12m_total']['new_assurers'];?></td>
122 <td class="DataTD"><?=$stats['growth_last_12m_total']['new_certificates'];?></td>
123 </tr>
124 </table>
125 <br>
126 <table align="center" border="0" cellspacing="0" cellpadding="0" class="wrapper">
127 <tr>
128 <td colspan="4" class="title">CAcert.org <?=_("Growth by year")?></td>
129 </tr>
130 <tr>
131 <td class="DataTD"><b><?=_("Date")?></b>
132 <td class="DataTD"><b><?=_("New Users")?></b>
133 <td class="DataTD"><b><?=_("New Assurers") . ' *'?></b>
134 <td class="DataTD"><b><?=_("New Certificates")?></b>
135 </tr>
136 <?
137 for($i = 0; $i < count($stats['growth_last_years']); $i++) {
138 ?>
139 <tr>
140 <td class="DataTD"><?=$stats['growth_last_years'][$i]['date'];?></td>
141 <td class="DataTD"><?=$stats['growth_last_years'][$i]['new_users'];?></td>
142 <td class="DataTD"><?=$stats['growth_last_years'][$i]['new_candidates'] . '/' . $stats['growth_last_years'][$i]['new_assurers'];?></td>
143 <td class="DataTD"><?=$stats['growth_last_years'][$i]['new_certificates'];?></td>
144 </tr>
145 <? } ?>
146 <tr>
147 <td class="DataTD"><?=_("Total")?></td>
148 <td class="DataTD"><?=$stats['growth_last_years_total']['new_users'];?></td>
149 <td class="DataTD"><?=$stats['growth_last_years_total']['new_candidates'] . '/' . $stats['growth_last_years_total']['new_assurers'];?></td>
150 <td class="DataTD"><?=$stats['growth_last_years_total']['new_certificates'];?></td>
151 </tr>
152 </table>
153 <br>
154
155 <div style="text-align: center;font-size: small;"><?
156 echo _('* user with at least 100 assurance points / assurer with CATS') . '</br>';
157 echo _('Difference of calculation of assurer between total and running total result from assurers that have been deleted from the system.') . '</br>';
158 printf(_("Last updated: %s"), date('Y-m-d H:i:s', $stats['timestamp']));?>
159 </div>
160
161 <? showfooter(); ?>