forked from Kak2X/jul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavatar.php
164 lines (138 loc) · 4.06 KB
/
avatar.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
<?php
// NoJS user switch
if (isset($_GET['go'])) {
if (!isset($_GET['usel'])) $_GET['usel'] = 0;
return header("Location: avatar.php?id={$_GET['usel']}");
}
require 'lib/function.php';
pageheader("Mood Avatar Preview", NULL, NULL, true); // Small header
$_GET['id'] = filter_int($_GET['id']);
// Admins get to see all of the avatars
// not like it matters when you can just access the userpic folder directly, but :V
$flags = AVATARS_ALL | ($isadmin ? 0 : AVATARS_NOHIDDEN);
$moods = get_avatars($_GET['id'], $flags);
if ($config['allow-avatar-storage']) {
// The user list
$users = $sql->query("
SELECT u.id, u.name, COUNT(*) avcount
FROM users u
INNER JOIN users_avatars a ON u.id = a.user
".($isadmin ? "" : "WHERE a.hidden = 0")."
GROUP BY u.id
");
} else {
// Build the select box options for the user selection
$users = $sql->query("
SELECT id, name, moodurl
FROM users
WHERE moodurl != ''
ORDER BY id ASC
");
}
$me = false;
$options = '';
while ($u = $sql->fetch($users)) {
// Selected user found
if ($u['id'] == $_GET['id']) {
$me = $u;
$selected = " selected";
} else {
$selected = "";
}
//if (!$config['allow-avatar-storage'] && strpos($u['moodurl'], '$') === FALSE)
// $fails = " (improper URL)";
$options .= "\r\n <option value='{$u['id']}'{$selected}>{$u['id']}: {$u['name']}</option>";
}
// The user was selected
if ($me && $moods) {
$_GET['start'] = filter_int($_GET['start']);
// Output the javascript right away
print include_js('avatars.js').
'<noscript><style type="text/css">.hideme{display: none}</style></noscript>';
if ($config['allow-avatar-storage']) {
$header_text = count($moods)." avatars found";
$avtype = "new"; // use newavatarpreview()
} else {
if ($_GET['start'] < 1) {
$_GET['start'] = 1;
}
$moodurl = htmlspecialchars($me['moodurl']);
$startimg = str_replace('$', $_GET['start'], $moodurl);
print set_mood_url_js($moodurl);
$header_text = $moodurl;
$avtype = ""; // use avatarpreview()
}
// Mood avatar selection
$txt = "";
$confirm = -1;
foreach ($moods as $num => $x) {
$jsclick = "onclick='{$avtype}avatarpreview({$me['id']},{$num},\"".escape_attribute($x['weblink'])."\")'";
if ($num == $_GET['start']) {
$selected = ' checked';
$confirm = $_GET['start']; // So no hidden or nonexisting avatars can be viewed
} else {
$selected = "";
}
$selected = ($num == $_GET['start']) ? ' checked' : '';
$txt .= "
<span class='hideme'>
<input type='radio' name='moodid' value='{$num}' id='mood{$num}' tabindex='". (9000 + $num) ."' style='height: 12px' {$jsclick} {$selected}>
<label for='mood{$num}' style='font-size: 12px'>
{$num}: {$x['title']}
</label>
</span>
<noscript> {$num}: <a href='?id={$_GET['id']}&start={$num}'>{$x['title']}</a></noscript><br>";
}
// Alternative header text
if ($config['allow-avatar-storage']) {
$startimg = $confirm != -1 ? avatar_path($me['id'], $confirm, $moods[$confirm]['weblink']) : "images/_.gif";
}
$ret = "<tr>
<td class='tdbgh center' colspan=2>
{$me['name']}: <i>{$header_text}</i>
</td>
</tr>
<tr style='height: 400px'>
<td class='tdbg1' style='width: 200px'>
<b>Mood avatar list:</b><br>
{$txt}
</td>
<td class='tdbg2 center' style='width: 400px'>
<img src=\"$startimg\" id=prev>
</td>
</tr>";
} else {
$ret = '';
}
?>
<script type="text/javascript">
function change_user(id) {
parent.location = 'avatar.php?id='+id;
}
</script>
<center>
<table height=100% valign=middle>
<tr>
<td>
<table class='table'>
<tr style='height: 50px'>
<td class='tdbgh center' colspan=2>
<b>Preview mood avatar for user...</b>
<br>
<form>
<select name="usel" onchange="change_user(this.options[this.selectedIndex].value)" style="width:500px;">
<option value=0><Select a user></option>
<?=$options?>
</select>
<noscript><input type="submit" name="go" value="Go"></noscript>
</form>
</td>
</tr>
<?=$ret?>
</table>
</td>
<tr>
</table>
</center>
</body>
</html>