-
Notifications
You must be signed in to change notification settings - Fork 1
/
userList.php
executable file
·233 lines (184 loc) · 5.37 KB
/
userList.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?php
/*
* UWS - Universal Wealth System
* userList.php
* GPL license
* author: Fabio Barone
* date: 30. Nov. 2009
*
* This file displays a list of all users, their balance
* and their correspondent share in percent on the
* total of services.
*
* It currently uses a third party library to display a
* pie chart of the shares per user. This library is a flash
* library, called through perc_chart.js. It is an opensource
* library with free license. However, clicking on the chart
* will lead the user to the originator of the library.
*
* The pie is of no use anyway as soon as a large numbers of users
* is in the system.
*
* For the library to work, this file creates a users.xml every time
* it gets called. The library needs this users.xml in order to
* create the pie chart.
*/
session_start();
include "config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
terrafirma1.0 by nodethirtythree design
http://www.nodethirtythree.com
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Universal Wealth System UWS</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="default.css" />
<script language="javascript">AC_FL_RunContent = 0;</script>
<script language="javascript"> DetectFlashVer = 0; </script>
<script src="charts/AC_RunActiveContent.js" language="javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 45;
-->
</script>
<BODY bgcolor="#FFFFFF">
<noscript>
<P>This content requires JavaScript.</P>
</noscript>
</head>
<body>
<div id="outer">
<div id="upbg"></div>
<div id="inner">
<?php include "header.php" ?>
<h3><?php echo translate("uws:reg_users") ?></h3>
<div class="date"><?php echo date('d F Y') ?></div> <!-- div date -->
</div><!-- div header -->
<div class="content">
<table class="nicetable" cellspacing="0">
<tr>
<th scope="col" abbr="User"><?php echo translate("uws:user") ?></th>
<th scope="col" abbr="Services"><?php echo translate("uws:services") ?></th>
<th scope="col" abbr="%"><?php echo translate("uws:srv_share") ?></th>
</tr>
<?php
$tdnorm = '<td class="spec">';
$tdalt = '<td class="specalt">';
$td = $tdnorm;
$users = array();
$perc_chart = array();
$total_balance = 0;
$total_perc = 0;
$sql = ("SELECT name,balance from members");
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query))
{
$user = $result['name'];
$balance = $result['balance'];
$users[$user] = $balance;
$total_balance += $balance;
}
$i=0;
// while ($user = current($users))
//reset($users);
foreach ($users as $user => $balance)
{
if ($balance != 0)
{
if ($i%2 != 0)
{
$td = $tdnorm;
} else
{
$td = $tdalt;
}
echo "<tr>";
//$user = key($users);
//$balance = $users[$user];
$perc = 0;
echo $td . "<a href=\"user.php?user=$user\">$user" . "</td>";
echo $td . $balance . "</td>";
if ($total_balance != 0)
{
$perc = ($balance/$total_balance) * 100;
$perc = round($perc,3);
$perc_chart[$user] = $perc;
}
$total_perc += $perc;
if ($perc == 0){
$perc = "< 0.001";
}
echo $td . $perc . "</td>";
echo "</tr>";
$i++;
}
}
create_chart_xml($perc_chart);
echo "<tr>";
echo "<th scope=\"col\" abbr=\"\">" . translate("uws:total") ."</th>";
echo "<th scope=\"col\" abbr=\"Total\">" . $total_balance ."</th>";
echo "<th scope=\"col\" abbr=\"\">" . $total_perc . "</th>";
echo "</tr>";
function create_chart_xml($perc_chart)
{
$fh = fopen("users.xml", "w");
fwrite($fh,"<chart>\n");
fwrite($fh,"\t<chart_data>\n");
fwrite($fh,"\t\t<row>\n");
fwrite($fh,"\t\t\t<null/>\n");
$userlist = array_keys($perc_chart);
foreach($userlist as $username)
{
fwrite($fh,"\t\t\t<string>" . $username . "</string>\n");
}
fwrite($fh,"\t\t</row>\n");
fwrite($fh,"\t\t<row>\n");
fwrite($fh,"\t\t\t<string>% of Total Services</string>\n");
$uservalues = array_values($perc_chart);
foreach($uservalues as $perc)
{
fwrite($fh,"\t\t\t<number>" . $perc . "</number>\n");
next($perc_chart);
}
fwrite($fh,"\t\t</row>\n");
fwrite($fh,"\t</chart_data>\n");
fwrite($fh,"\t<chart_type>Pie");
fwrite($fh,"</chart_type>\n");
fwrite($fh,"</chart>\n");
fclose($fh);
}
?>
</table><br><br>
</div>
<div class="content"> <!--chart -->
<script src="perc_chart.js" type="text/javascript"></script>
</div>
<div class="footer">
<ul>
<li class="printerfriendly"><a href="#">Printer Friendly</a></li>
<li class="readmore"><a href="#">Read more</a></li>
</ul>
</div>
</div>
</div>
<div id="secondarycontent">
<!-- Displaying lists links -->
<?php include "lists.php" ?>
<!-- Displaying action links -->
<?php include "actions.php" ?>
<!-- secondary content end -->
</div>
<div id="footer">
© UWS. </a>.
</div>
</div>
</div>
</body>
</html>