-
Notifications
You must be signed in to change notification settings - Fork 13
/
AP_Languages_and_styles.php
176 lines (161 loc) · 5.06 KB
/
AP_Languages_and_styles.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
<?php
/**
* This plugin allows forum administrators to reset the language and style
* settings for all users. It also displays usage statistics for the different
* languages and styles.
*
* Copyright (C) 2005 Connor Dunn ([email protected])
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
*/
// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
exit;
// Tell admin_loader.php that this is indeed a plugin and that it is loaded
define('PUN_PLUGIN_LOADED', 1);
define('PLUGIN_VERSION',1.0);
function RoundSigDigs($number, $sigdigs) {
$multiplier = 1;
while ($number < 0.1) {
$number *= 10;
$multiplier /= 10;
}
while ($number >= 1) {
$number /= 10;
$multiplier *= 10;
}
return round($number, $sigdigs) * $multiplier;
}
if (isset($_POST['lang']))
{
// Do Post
$db->query('UPDATE '.$db->prefix.'users SET language=\''.$_POST['form']['language'].'\' WHERE id>1') or error('Unable to set lang settings', __FILE__, __LINE__, $db->error());
redirect($_SERVER['REQUEST_URI'], 'Languages Reset');
}
elseif (isset($_POST['style']))
{
// Do Post
$db->query('UPDATE '.$db->prefix.'users SET style=\''.$_POST['form']['style'].'\' WHERE id>1') or error('Unable to set style settings', __FILE__, __LINE__, $db->error());
redirect($_SERVER['REQUEST_URI'], 'Styles Reset');
}
else // If not, we show the form
{
// Display the admin navigation menu
generate_admin_menu($plugin);
?>
<div id="exampleplugin" class="plugin blockform">
<h2><span>Language and style statistics/resetter - v<?php echo PLUGIN_VERSION ?></span></h2>
<div class="box">
<div class="inbox">
<p>This Plugin allows you to see the style and language settings of users and reset them.</p>
</div>
</div>
</div>
<div class="blockform">
<h2 class="block2"><span>Languages</span></h2>
<div class="box">
<form id="lang" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
<div class="inform">
<fieldset>
<legend>Languages</legend>
<div class="infldset">
<table class="aligntop" cellspacing="0">
<tr>
<th scope="row">Language Usage</th>
<td>
<?php
$result = $db->query('SELECT language, count(*) as number FROM '.$db->prefix.'users WHERE id > 1 GROUP BY language ORDER BY number') or error('Unable to fetch lang settings', __FILE__, __LINE__, $db->error());
$number = $db->num_rows($db->query('SELECT username from '.$db->prefix.'users WHERE id > 1'));
while ($cur_lang = $db->fetch_assoc($result)) {
echo RoundSigDigs($cur_lang['number'] / $number * 100,3).'% '.str_replace('_',' ',$cur_lang['language']).'<br />';
}
?>
</td>
</tr>
<tr>
<th scope="row">Language</th>
<td>
<?php
$languages = array();
$d = dir(PUN_ROOT.'lang');
while (($entry = $d->read()) !== false)
{
if ($entry != '.' && $entry != '..' && is_dir(PUN_ROOT.'lang/'.$entry))
$languages[] = $entry;
}
$d->close();
?>
<select name="form[language]">
<?php
while (list(, $temp) = @each($languages))
{
echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n";
}
?>
</select>
<span>All users languages will be reset to this option.</span>
</td>
</tr>
</table>
</div>
</fieldset>
</div>
<p class="submitend"><input type="submit" name="lang" value="Reset!" tabindex="2" /></p>
</form>
</div>
</div>
<div class="blockform">
<h2 class="block2"><span>Styles</span></h2>
<div class="box">
<form id="style" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
<div class="inform">
<fieldset>
<legend>Styles</legend>
<div class="infldset">
<table class="aligntop" cellspacing="0">
<tr>
<th scope="row">Style Usage</th>
<td>
<?php
$result = $db->query('SELECT style, count(*) as number FROM '.$db->prefix.'users WHERE id > 1 GROUP BY style ORDER BY number') or error('Unable to fetch style settings', __FILE__, __LINE__, $db->error());
$number = $db->num_rows($db->query('SELECT username from '.$db->prefix.'users WHERE id > 1'));
while ($cur_lang = $db->fetch_assoc($result)) {
echo RoundSigDigs($cur_lang['number'] / $number * 100,3).'% '.str_replace('_',' ',$cur_lang['style']).'<br />';
}
?>
</td>
</tr>
<tr>
<th scope="row">Style</th>
<td>
<?php
$styles = array();
$d = dir(PUN_ROOT.'style');
while (($entry = $d->read()) !== false)
{
if (substr($entry, strlen($entry)-4) == '.css')
$styles[] = substr($entry, 0, strlen($entry)-4);
}
$d->close();
?>
<select name="form[style]">
<?php
while (list(, $temp) = @each($styles))
{
echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.str_replace('_', ' ', $temp).'</option>'."\n";
}
?>
</select>
<span>All users styles will be reset to this option.</span>
</td>
</tr>
</table>
</div>
</fieldset>
</div>
<p class="submitend"><input type="submit" name="style" value="Reset!" tabindex="2" /></p>
</form>
</div>
</div>
<?php
}
?>