1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
function main_page() : void { |
4
|
|
|
$db = Smr\Database::getInstance(); |
5
|
|
|
$session = Smr\Session::getInstance(); |
6
|
|
|
|
7
|
|
|
// list of all first letter nicks |
8
|
|
|
create_link_list(); |
9
|
|
|
|
10
|
|
|
// news |
11
|
|
|
echo('<p><u>Space Merchant Realms Photo Album Rules</u>'); |
12
|
|
|
echo('<ol>'); |
13
|
|
|
echo('<li>500 x 500 pixel maximum photo size.</li>'); |
14
|
|
|
echo('<li>Only .jpg, .png, or .gif files will be accepted.</li>'); |
15
|
|
|
echo('<li>No derogatory or vulgar pictures will be accepted.</li>'); |
16
|
|
|
echo('<li>Pictures MUST depict the real you. No anime, fictional, or otherwise \'fake\' pictures are allowed.</li>'); |
17
|
|
|
echo('<li>Please watch your language while posting within the album. Same general rules apply here as in SMR chat rooms.</li>'); |
18
|
|
|
echo('<li>Please respect all members in this area. Treat them as you would want to be treated. Do not post cruel or otherwise unneeded comments about someone or their property.</li>'); |
19
|
|
|
echo('<li>You must be logged into your account to post within this album. Therefore, if you break any of these rules, your account may be subject to disablement.</li>'); |
20
|
|
|
echo('</ol>'); |
21
|
|
|
echo('<small><b>Please Note:</b> This is your only warning! All rule violations (even first time offenders) will be subject to a 1-day ban. Repeat offenders may incur longer bans.</small>'); |
22
|
|
|
echo('</p>'); |
23
|
|
|
|
24
|
|
|
echo('<p> </p>'); |
25
|
|
|
|
26
|
|
|
// most hits |
27
|
|
|
echo('<p><u>Top 5 Pictures</u><br /><br />'); |
28
|
|
|
$dbResult = $db->read('SELECT * |
29
|
|
|
FROM album |
30
|
|
|
WHERE approved = \'YES\' |
31
|
|
|
ORDER BY page_views DESC |
32
|
|
|
LIMIT 5'); |
33
|
|
|
foreach ($dbResult->records() as $dbRecord) { |
34
|
|
|
$page_views = $dbRecord->getInt('page_views'); |
35
|
|
|
$nick = get_album_nick($dbRecord->getInt('account_id')); |
36
|
|
|
|
37
|
|
|
echo('<a href="?nick=' . urlencode($nick) . '">' . $nick . '</a> (' . $page_views . ')<br />'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
// latest picture |
41
|
|
|
$dateFormat = $session->hasAccount() ? $session->getAccount()->getDateTimeFormat() : DEFAULT_DATE_TIME_FORMAT; |
42
|
|
|
echo('<p><u>Latest Picture</u><br /><br />'); |
43
|
|
|
$dbResult = $db->read('SELECT * |
44
|
|
|
FROM album |
45
|
|
|
WHERE approved = \'YES\' |
46
|
|
|
ORDER BY created DESC |
47
|
|
|
LIMIT 5'); |
48
|
|
|
if ($dbResult->hasRecord()) { |
49
|
|
|
foreach ($dbResult->records() as $dbRecord) { |
50
|
|
|
$created = $dbRecord->getInt('created'); |
51
|
|
|
$nick = get_album_nick($dbRecord->getInt('account_id')); |
52
|
|
|
|
53
|
|
|
echo('<span style="font-size:85%;"><b>[' . date($dateFormat, $created) . ']</b> Picture of <a href="?nick=' . urlencode($nick) . '">' . $nick . '</a> added</span><br />'); |
54
|
|
|
} |
55
|
|
|
} else { |
56
|
|
|
echo('<span style="font-size:85%;">no entries</span>'); |
57
|
|
|
} |
58
|
|
|
echo('</p>'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
function album_entry(int $album_id) : void { |
62
|
|
|
$db = Smr\Database::getInstance(); |
63
|
|
|
$session = Smr\Session::getInstance(); |
64
|
|
|
|
65
|
|
|
// list of all first letter nicks |
66
|
|
|
create_link_list(); |
67
|
|
|
|
68
|
|
|
if ($session->hasAccount() && $album_id != $session->getAccountID()) { |
69
|
|
|
$db->write('UPDATE album |
70
|
|
|
SET page_views = page_views + 1 |
71
|
|
|
WHERE account_id = '.$db->escapeNumber($album_id) . ' AND |
72
|
|
|
approved = \'YES\''); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$dbResult = $db->read('SELECT * |
76
|
|
|
FROM album |
77
|
|
|
WHERE account_id = '.$db->escapeNumber($album_id) . ' AND |
78
|
|
|
approved = \'YES\''); |
79
|
|
|
if ($dbResult->hasRecord()) { |
80
|
|
|
$dbRecord = $dbResult->record(); |
81
|
|
|
$location = $dbRecord->getField('location'); |
82
|
|
|
$email = $dbRecord->getField('email'); |
83
|
|
|
$website = $dbRecord->getField('website'); |
84
|
|
|
$day = $dbRecord->getField('day'); |
85
|
|
|
$month = $dbRecord->getField('month'); |
86
|
|
|
$year = $dbRecord->getField('year'); |
87
|
|
|
$other = nl2br($dbRecord->getField('other')); |
|
|
|
|
88
|
|
|
$page_views = $dbRecord->getInt('page_views'); |
89
|
|
|
$disabled = $dbRecord->getBoolean('disabled'); |
90
|
|
|
} else { |
91
|
|
|
echo('<h1>Error</h1>'); |
92
|
|
|
echo('This user doesn\'t have an entry in our album!'); |
93
|
|
|
return; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
// get this user's nick |
97
|
|
|
$nick = get_album_nick($album_id); |
98
|
|
|
|
99
|
|
|
echo('<table border="0" cellpadding="5" cellspacing="0">'); |
100
|
|
|
echo('<tr>'); |
101
|
|
|
echo('<td colspan="2">'); |
102
|
|
|
echo '<div style="margin-left: auto; margin-right: auto; width: 50%">'; |
103
|
|
|
echo('<table style="width: 100%">'); |
104
|
|
|
echo('<tr>'); |
105
|
|
|
|
106
|
|
|
$dbResult = $db->read('SELECT hof_name |
107
|
|
|
FROM album JOIN account USING(account_id) |
108
|
|
|
WHERE hof_name < ' . $db->escapeString($nick) . ' AND |
109
|
|
|
approved = \'YES\' |
110
|
|
|
ORDER BY hof_name DESC |
111
|
|
|
LIMIT 1'); |
112
|
|
|
echo '<td class="center" style="width: 30%" valign="middle">'; |
113
|
|
|
if ($dbResult->hasRecord()) { |
114
|
|
|
$priv_nick = $dbResult->record()->getString('hof_name'); |
115
|
|
|
echo '<a href="?nick=' . urlencode($priv_nick) . '"><img src="/images/album/rew.jpg" alt="' . $priv_nick . '" border="0"></a> '; |
116
|
|
|
} |
117
|
|
|
echo '</td>'; |
118
|
|
|
echo('<td class="center" valign="middle"><span style="font-size:150%;">' . $nick . '</span><br /><span style="font-size:75%;">Views: ' . $page_views . '</span></td>'); |
119
|
|
|
|
120
|
|
|
$dbResult = $db->read('SELECT hof_name |
121
|
|
|
FROM album JOIN account USING(account_id) |
122
|
|
|
WHERE hof_name > ' . $db->escapeString($nick) . ' AND |
123
|
|
|
approved = \'YES\' |
124
|
|
|
ORDER BY hof_name |
125
|
|
|
LIMIT 1'); |
126
|
|
|
echo '<td class="center" style="width: 30%" valign="middle">'; |
127
|
|
|
if ($dbResult->hasRecord()) { |
128
|
|
|
$next_nick = $dbResult->record()->getField('hof_name'); |
129
|
|
|
echo ' <a href="?nick=' . urlencode($next_nick) . '"><img src="/images/album/fwd.jpg" alt="' . $next_nick . '" border="0"></a>'; |
|
|
|
|
130
|
|
|
} |
131
|
|
|
echo '</td>'; |
132
|
|
|
|
133
|
|
|
echo('</tr>'); |
134
|
|
|
echo('</table>'); |
135
|
|
|
echo '</div>'; |
136
|
|
|
echo('</td>'); |
137
|
|
|
echo('</tr>'); |
138
|
|
|
echo('<tr>'); |
139
|
|
|
echo('<td colspan="2" class="center" valign="middle">'); |
140
|
|
|
|
141
|
|
|
if ($disabled === false) { |
142
|
|
|
echo('<img src="../upload/' . $album_id . '">'); |
143
|
|
|
} else { |
144
|
|
|
echo('<img src="../images/album/disabled.jpg">'); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
echo('</td>'); |
148
|
|
|
echo('</tr>'); |
149
|
|
|
|
150
|
|
|
if (empty($location)) { |
151
|
|
|
$location = 'N/A'; |
152
|
|
|
} |
153
|
|
|
echo('<tr>'); |
154
|
|
|
echo('<td class="right bold" width="10%">Location:</td><td>' . $location . '</td>'); |
155
|
|
|
echo('</tr>'); |
156
|
|
|
|
157
|
|
|
if (empty($email)) { |
158
|
|
|
$email = 'N/A'; |
159
|
|
|
} |
160
|
|
|
echo('<tr>'); |
161
|
|
|
echo('<td class="right bold" width="10%">E-mail:</td><td>' . $email . '</td>'); |
162
|
|
|
echo('</tr>'); |
163
|
|
|
|
164
|
|
|
if (empty($website)) { |
165
|
|
|
$website = 'N/A'; |
166
|
|
|
} else { |
167
|
|
|
$website = '<a href="' . $website . '" target="_new">' . $website . '</a>'; |
168
|
|
|
} |
169
|
|
|
echo('<tr>'); |
170
|
|
|
echo('<td class="right bold" width="10%">Website:</td><td>' . $website . '</td>'); |
171
|
|
|
echo('</tr>'); |
172
|
|
|
|
173
|
|
|
echo('<tr>'); |
174
|
|
|
if (!empty($day) && !empty($month) && !empty($year)) { |
175
|
|
|
$birthdate = $month . ' / ' . $day . ' / ' . $year; |
176
|
|
|
} |
177
|
|
|
if (empty($birthdate) && !empty($year)) { |
178
|
|
|
$birthdate = 'Year ' . $year; |
179
|
|
|
} |
180
|
|
|
if (empty($birthdate)) { |
181
|
|
|
$birthdate = 'N/A'; |
182
|
|
|
} |
183
|
|
|
echo('<td class="right bold" width="10%">Birthdate:</td><td>' . $birthdate . '</td>'); |
184
|
|
|
echo('</tr>'); |
185
|
|
|
|
186
|
|
|
if (empty($other)) { |
187
|
|
|
$other = 'N/A'; |
188
|
|
|
} |
189
|
|
|
echo('<tr>'); |
190
|
|
|
echo('<td class="right bold" valign="top" width="10%">Other Info:</td><td>' . $other . '</td>'); |
191
|
|
|
echo('</tr>'); |
192
|
|
|
|
193
|
|
|
echo('<tr>'); |
194
|
|
|
echo('<td colspan="2">'); |
195
|
|
|
echo('<u>Comments</u><br /><br />'); |
196
|
|
|
|
197
|
|
|
$dateFormat = $session->hasAccount() ? $session->getAccount()->getDateTimeFormat() : DEFAULT_DATE_TIME_FORMAT; |
198
|
|
|
$dbResult = $db->read('SELECT * |
199
|
|
|
FROM album_has_comments |
200
|
|
|
WHERE album_id = '.$db->escapeNumber($album_id)); |
201
|
|
|
foreach ($dbResult->records() as $dbRecord) { |
202
|
|
|
$time = $dbRecord->getInt('time'); |
203
|
|
|
$postee = get_album_nick($dbRecord->getInt('post_id')); |
204
|
|
|
$msg = $dbRecord->getString('msg'); |
205
|
|
|
|
206
|
|
|
echo('<span style="font-size:85%;">[' . date($dateFormat, $time) . '] <' . $postee . '> ' . $msg . '</span><br />'); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
if ($session->hasAccount()) { |
210
|
|
|
echo('<form action="album_comment.php">'); |
211
|
|
|
echo('<input type="hidden" name="album_id" value="' . $album_id . '">'); |
212
|
|
|
echo('<table>'); |
213
|
|
|
echo('<tr>'); |
214
|
|
|
echo('<td style="color:green; font-size:70%;">Nick:<br /><input type="text" size="10" name="nick" value="' . htmlspecialchars(get_album_nick($session->getAccountID())) . '" readonly></td>'); |
215
|
|
|
echo('<td style="color:green; font-size:70%;">Comment:<br /><input type="text" size="50" name="comment"></td>'); |
216
|
|
|
echo('<td style="color:green; font-size:70%;"><br /><input type="submit" value="Send"></td>'); |
217
|
|
|
$dbResult = $db->read('SELECT 1 |
218
|
|
|
FROM account_has_permission |
219
|
|
|
WHERE account_id = '.$db->escapeNumber($session->getAccountID()) . ' AND |
220
|
|
|
permission_id = '.$db->escapeNumber(PERMISSION_MODERATE_PHOTO_ALBUM)); |
221
|
|
|
if ($dbResult->hasRecord()) { |
222
|
|
|
echo('<td style="color:green; font-size:70%;"><br /><input type="submit" name="action" value="Moderate"></td>'); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
echo('</tr>'); |
226
|
|
|
echo('</table>'); |
227
|
|
|
echo('</form>'); |
228
|
|
|
} else { |
229
|
|
|
echo('<p>Please <a href="/login.php?return_page=/album/?nick=' . urlencode($nick) . '"><u>login</u></a> if you want comment on this picture!</p>'); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
echo('</td>'); |
233
|
|
|
echo('</tr>'); |
234
|
|
|
echo('</table>'); |
235
|
|
|
|
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
function search_result(array $album_ids) : void { |
239
|
|
|
|
240
|
|
|
// list of all first letter nicks |
241
|
|
|
create_link_list(); |
242
|
|
|
|
243
|
|
|
echo('<div class="center big">Please make a selection!</div>'); |
244
|
|
|
|
245
|
|
|
echo('<table border="0" class="center" cellpadding="5" cellspacing="0">'); |
246
|
|
|
|
247
|
|
|
$count = 0; |
248
|
|
|
echo('<tr><td class="left" width="25%" valign="top">'); |
249
|
|
|
|
250
|
|
|
foreach ($album_ids as $album_id) { |
251
|
|
|
$count++; |
252
|
|
|
|
253
|
|
|
$nick = get_album_nick($album_id); |
254
|
|
|
|
255
|
|
|
echo('<a href="?nick=' . urlencode($nick) . '" style="font-size:80%;">' . $nick . '</a><br />'); |
256
|
|
|
|
257
|
|
|
if (floor(count($album_ids) / 4) > 0 && $count % floor(count($album_ids) / 4) == 0) { |
258
|
|
|
echo('</td><td width="25%" valign="top">'); |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
echo('</td></tr>'); |
262
|
|
|
echo('</table>'); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
function create_link_list() : void { |
266
|
|
|
echo('<div class="center" style="font-size:80%;">[ '); |
267
|
|
|
echo('<a href="?nick=%">All</a> | '); |
268
|
|
|
echo('<a href="?nick=A">A</a> | '); |
269
|
|
|
echo('<a href="?nick=B">B</a> | '); |
270
|
|
|
echo('<a href="?nick=C">C</a> | '); |
271
|
|
|
echo('<a href="?nick=D">D</a> | '); |
272
|
|
|
echo('<a href="?nick=E">E</a> | '); |
273
|
|
|
echo('<a href="?nick=F">F</a> | '); |
274
|
|
|
echo('<a href="?nick=G">G</a> | '); |
275
|
|
|
echo('<a href="?nick=H">H</a> | '); |
276
|
|
|
echo('<a href="?nick=I">I</a> | '); |
277
|
|
|
echo('<a href="?nick=J">J</a> | '); |
278
|
|
|
echo('<a href="?nick=K">K</a> | '); |
279
|
|
|
echo('<a href="?nick=L">L</a> | '); |
280
|
|
|
echo('<a href="?nick=M">M</a> | '); |
281
|
|
|
echo('<a href="?nick=N">N</a> | '); |
282
|
|
|
echo('<a href="?nick=O">O</a> | '); |
283
|
|
|
echo('<a href="?nick=P">P</a> | '); |
284
|
|
|
echo('<a href="?nick=Q">Q</a> | '); |
285
|
|
|
echo('<a href="?nick=R">R</a> | '); |
286
|
|
|
echo('<a href="?nick=S">S</a> | '); |
287
|
|
|
echo('<a href="?nick=T">T</a> | '); |
288
|
|
|
echo('<a href="?nick=U">U</a> | '); |
289
|
|
|
echo('<a href="?nick=V">V</a> | '); |
290
|
|
|
echo('<a href="?nick=W">W</a> | '); |
291
|
|
|
echo('<a href="?nick=X">X</a> | '); |
292
|
|
|
echo('<a href="?nick=Y">Y</a> | '); |
293
|
|
|
echo('<a href="?nick=Z">Z</a> ]</div>'); |
294
|
|
|
echo('<hr class="center">'); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
|
298
|
|
|
|
299
|
|
|
function get_album_nick(int $album_id) : string { |
300
|
|
|
if ($album_id == 0) { |
301
|
|
|
return 'System'; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
return SmrAccount::getAccount($album_id)->getHofName(); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/* |
308
|
|
|
AddHandler catch-all-handler .php |
309
|
|
|
Action catch-all-handler /home/mrspock/smrealms.de/beta/www/album/index.php |
310
|
|
|
*/ |
311
|
|
|
|