1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | /** |
---|
25 | * Display filtered history lines |
---|
26 | */ |
---|
27 | |
---|
28 | // +-----------------------------------------------------------------------+ |
---|
29 | // | functions | |
---|
30 | // +-----------------------------------------------------------------------+ |
---|
31 | |
---|
32 | // +-----------------------------------------------------------------------+ |
---|
33 | // | initialization | |
---|
34 | // +-----------------------------------------------------------------------+ |
---|
35 | |
---|
36 | if (!defined('PHPWG_ROOT_PATH')) |
---|
37 | { |
---|
38 | die('Hacking attempt!'); |
---|
39 | } |
---|
40 | |
---|
41 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
42 | include_once(PHPWG_ROOT_PATH.'admin/include/functions_history.inc.php'); |
---|
43 | |
---|
44 | if (isset($_GET['start']) and is_numeric($_GET['start'])) |
---|
45 | { |
---|
46 | $page['start'] = $_GET['start']; |
---|
47 | } |
---|
48 | else |
---|
49 | { |
---|
50 | $page['start'] = 0; |
---|
51 | } |
---|
52 | |
---|
53 | $types = array('none', 'picture', 'high', 'other'); |
---|
54 | |
---|
55 | $display_thumbnails = array('no_display_thumbnail' => l10n('No display'), |
---|
56 | 'display_thumbnail_classic' => l10n('Classic display'), |
---|
57 | 'display_thumbnail_hoverbox' => l10n('Hoverbox display') |
---|
58 | ); |
---|
59 | |
---|
60 | // +-----------------------------------------------------------------------+ |
---|
61 | // | Check Access and exit when user status is not ok | |
---|
62 | // +-----------------------------------------------------------------------+ |
---|
63 | |
---|
64 | check_status(ACCESS_ADMINISTRATOR); |
---|
65 | |
---|
66 | // +-----------------------------------------------------------------------+ |
---|
67 | // | Build search criteria and redirect to results | |
---|
68 | // +-----------------------------------------------------------------------+ |
---|
69 | |
---|
70 | $page['errors'] = array(); |
---|
71 | $search = array(); |
---|
72 | |
---|
73 | if (isset($_POST['submit'])) |
---|
74 | { |
---|
75 | // dates |
---|
76 | if (!empty($_POST['start_year'])) |
---|
77 | { |
---|
78 | $search['fields']['date-after'] = sprintf( |
---|
79 | '%d-%02d-%02d', |
---|
80 | $_POST['start_year'], |
---|
81 | $_POST['start_month'], |
---|
82 | $_POST['start_day'] |
---|
83 | ); |
---|
84 | } |
---|
85 | |
---|
86 | if (!empty($_POST['end_year'])) |
---|
87 | { |
---|
88 | $search['fields']['date-before'] = sprintf( |
---|
89 | '%d-%02d-%02d', |
---|
90 | $_POST['end_year'], |
---|
91 | $_POST['end_month'], |
---|
92 | $_POST['end_day'] |
---|
93 | ); |
---|
94 | } |
---|
95 | |
---|
96 | if (empty($_POST['types'])) |
---|
97 | { |
---|
98 | $search['fields']['types'] = $types; |
---|
99 | } |
---|
100 | else |
---|
101 | { |
---|
102 | $search['fields']['types'] = $_POST['types']; |
---|
103 | } |
---|
104 | |
---|
105 | $search['fields']['user'] = $_POST['user']; |
---|
106 | |
---|
107 | if (!empty($_POST['image_id'])) |
---|
108 | { |
---|
109 | $search['fields']['image_id'] = intval($_POST['image_id']); |
---|
110 | } |
---|
111 | |
---|
112 | if (!empty($_POST['filename'])) |
---|
113 | { |
---|
114 | $search['fields']['filename'] = str_replace( |
---|
115 | '*', |
---|
116 | '%', |
---|
117 | pwg_db_real_escape_string($_POST['filename']) |
---|
118 | ); |
---|
119 | } |
---|
120 | |
---|
121 | $search['fields']['display_thumbnail'] = $_POST['display_thumbnail']; |
---|
122 | // Display choise are also save to one cookie |
---|
123 | if (!empty($_POST['display_thumbnail']) |
---|
124 | and isset($display_thumbnails[$_POST['display_thumbnail']])) |
---|
125 | { |
---|
126 | $cookie_val = $_POST['display_thumbnail']; |
---|
127 | } |
---|
128 | else |
---|
129 | { |
---|
130 | $cookie_val = null; |
---|
131 | } |
---|
132 | |
---|
133 | pwg_set_cookie_var('display_thumbnail', $cookie_val, strtotime('+1 month') ); |
---|
134 | |
---|
135 | // TODO manage inconsistency of having $_POST['image_id'] and |
---|
136 | // $_POST['filename'] simultaneously |
---|
137 | |
---|
138 | if (!empty($search)) |
---|
139 | { |
---|
140 | // register search rules in database, then they will be available on |
---|
141 | // thumbnails page and picture page. |
---|
142 | $query =' |
---|
143 | INSERT INTO '.SEARCH_TABLE.' |
---|
144 | (rules) |
---|
145 | VALUES |
---|
146 | (\''.serialize($search).'\') |
---|
147 | ;'; |
---|
148 | pwg_query($query); |
---|
149 | |
---|
150 | $search_id = pwg_db_insert_id(SEARCH_TABLE); |
---|
151 | |
---|
152 | redirect( |
---|
153 | PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id |
---|
154 | ); |
---|
155 | } |
---|
156 | else |
---|
157 | { |
---|
158 | array_push($page['errors'], l10n('Empty query. No criteria has been entered.')); |
---|
159 | } |
---|
160 | } |
---|
161 | |
---|
162 | // +-----------------------------------------------------------------------+ |
---|
163 | // | template init | |
---|
164 | // +-----------------------------------------------------------------------+ |
---|
165 | |
---|
166 | $template->set_filename('history', 'history.tpl'); |
---|
167 | |
---|
168 | // TabSheet initialization |
---|
169 | history_tabsheet(); |
---|
170 | |
---|
171 | $template->assign( |
---|
172 | array( |
---|
173 | 'U_HELP' => get_root_url().'admin/popuphelp.php?page=history', |
---|
174 | 'F_ACTION' => get_root_url().'admin.php?page=history' |
---|
175 | ) |
---|
176 | ); |
---|
177 | |
---|
178 | // +-----------------------------------------------------------------------+ |
---|
179 | // | history lines | |
---|
180 | // +-----------------------------------------------------------------------+ |
---|
181 | |
---|
182 | if (isset($_GET['search_id']) |
---|
183 | and $page['search_id'] = (int)$_GET['search_id']) |
---|
184 | { |
---|
185 | // what are the lines to display in reality ? |
---|
186 | $query = ' |
---|
187 | SELECT rules |
---|
188 | FROM '.SEARCH_TABLE.' |
---|
189 | WHERE id = '.$page['search_id'].' |
---|
190 | ;'; |
---|
191 | list($serialized_rules) = pwg_db_fetch_row(pwg_query($query)); |
---|
192 | |
---|
193 | $page['search'] = unserialize($serialized_rules); |
---|
194 | |
---|
195 | if (isset($_GET['user_id'])) |
---|
196 | { |
---|
197 | if (!is_numeric($_GET['user_id'])) |
---|
198 | { |
---|
199 | die('user_id GET parameter must be an integer value'); |
---|
200 | } |
---|
201 | |
---|
202 | $page['search']['fields']['user'] = $_GET['user_id']; |
---|
203 | |
---|
204 | $query =' |
---|
205 | INSERT INTO '.SEARCH_TABLE.' |
---|
206 | (rules) |
---|
207 | VALUES |
---|
208 | (\''.serialize($page['search']).'\') |
---|
209 | ;'; |
---|
210 | pwg_query($query); |
---|
211 | |
---|
212 | $search_id = pwg_db_insert_id(SEARCH_TABLE); |
---|
213 | |
---|
214 | redirect( |
---|
215 | PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id |
---|
216 | ); |
---|
217 | } |
---|
218 | |
---|
219 | $data = trigger_event('get_history', array(), $page['search'], $types); |
---|
220 | usort($data, 'history_compare'); |
---|
221 | |
---|
222 | $page['nb_lines'] = count($data); |
---|
223 | |
---|
224 | $history_lines = array(); |
---|
225 | $user_ids = array(); |
---|
226 | $username_of = array(); |
---|
227 | $category_ids = array(); |
---|
228 | $image_ids = array(); |
---|
229 | $tag_ids = array(); |
---|
230 | |
---|
231 | foreach ($data as $row) |
---|
232 | { |
---|
233 | $user_ids[$row['user_id']] = 1; |
---|
234 | |
---|
235 | if (isset($row['category_id'])) |
---|
236 | { |
---|
237 | $category_ids[$row['category_id']] = 1; |
---|
238 | } |
---|
239 | |
---|
240 | if (isset($row['image_id'])) |
---|
241 | { |
---|
242 | $image_ids[$row['image_id']] = 1; |
---|
243 | } |
---|
244 | |
---|
245 | if (isset($row['tag_ids'])) |
---|
246 | { |
---|
247 | foreach (explode(',', $row['tag_ids']) as $tag_id) |
---|
248 | { |
---|
249 | array_push($tag_ids, $tag_id); |
---|
250 | } |
---|
251 | } |
---|
252 | |
---|
253 | array_push( |
---|
254 | $history_lines, |
---|
255 | $row |
---|
256 | ); |
---|
257 | } |
---|
258 | |
---|
259 | // prepare reference data (users, tags, categories...) |
---|
260 | if (count($user_ids) > 0) |
---|
261 | { |
---|
262 | $query = ' |
---|
263 | SELECT '.$conf['user_fields']['id'].' AS id |
---|
264 | , '.$conf['user_fields']['username'].' AS username |
---|
265 | FROM '.USERS_TABLE.' |
---|
266 | WHERE id IN ('.implode(',', array_keys($user_ids)).') |
---|
267 | ;'; |
---|
268 | $result = pwg_query($query); |
---|
269 | |
---|
270 | $username_of = array(); |
---|
271 | while ($row = pwg_db_fetch_assoc($result)) |
---|
272 | { |
---|
273 | $username_of[$row['id']] = stripslashes($row['username']); |
---|
274 | } |
---|
275 | } |
---|
276 | |
---|
277 | if (count($category_ids) > 0) |
---|
278 | { |
---|
279 | $query = ' |
---|
280 | SELECT id, uppercats |
---|
281 | FROM '.CATEGORIES_TABLE.' |
---|
282 | WHERE id IN ('.implode(',', array_keys($category_ids)).') |
---|
283 | ;'; |
---|
284 | $uppercats_of = simple_hash_from_query($query, 'id', 'uppercats'); |
---|
285 | |
---|
286 | $name_of_category = array(); |
---|
287 | |
---|
288 | foreach ($uppercats_of as $category_id => $uppercats) |
---|
289 | { |
---|
290 | $name_of_category[$category_id] = get_cat_display_name_cache( |
---|
291 | $uppercats |
---|
292 | ); |
---|
293 | } |
---|
294 | } |
---|
295 | |
---|
296 | if (count($image_ids) > 0) |
---|
297 | { |
---|
298 | $query = ' |
---|
299 | SELECT |
---|
300 | id, |
---|
301 | IF(name IS NULL, file, name) AS label, |
---|
302 | filesize, |
---|
303 | high_filesize, |
---|
304 | file, |
---|
305 | path, |
---|
306 | tn_ext |
---|
307 | FROM '.IMAGES_TABLE.' |
---|
308 | WHERE id IN ('.implode(',', array_keys($image_ids)).') |
---|
309 | ;'; |
---|
310 | // $label_of_image = simple_hash_from_query($query, 'id', 'label'); |
---|
311 | $label_of_image = array(); |
---|
312 | $filesize_of_image = array(); |
---|
313 | $high_filesize_of_image = array(); |
---|
314 | $file_of_image = array(); |
---|
315 | $path_of_image = array(); |
---|
316 | $tn_ext_of_image = array(); |
---|
317 | |
---|
318 | $result = pwg_query($query); |
---|
319 | while ($row = pwg_db_fetch_assoc($result)) |
---|
320 | { |
---|
321 | $label_of_image[ $row['id'] ] = $row['label']; |
---|
322 | |
---|
323 | if (isset($row['filesize'])) |
---|
324 | { |
---|
325 | $filesize_of_image[ $row['id'] ] = $row['filesize']; |
---|
326 | } |
---|
327 | |
---|
328 | if (isset($row['high_filesize'])) |
---|
329 | { |
---|
330 | $high_filesize_of_image[ $row['id'] ] = $row['high_filesize']; |
---|
331 | } |
---|
332 | |
---|
333 | $file_of_image[ $row['id'] ] = $row['file']; |
---|
334 | $path_of_image[ $row['id'] ] = $row['path']; |
---|
335 | $tn_ext_of_image[ $row['id'] ] = $row['tn_ext']; |
---|
336 | } |
---|
337 | |
---|
338 | // echo '<pre>'; print_r($high_filesize_of_image); echo '</pre>'; |
---|
339 | } |
---|
340 | |
---|
341 | if (count($tag_ids) > 0) |
---|
342 | { |
---|
343 | $tag_ids = array_unique($tag_ids); |
---|
344 | |
---|
345 | $query = ' |
---|
346 | SELECT |
---|
347 | id, |
---|
348 | name |
---|
349 | FROM '.TAGS_TABLE.' |
---|
350 | WHERE id IN ('.implode(', ', $tag_ids).') |
---|
351 | ;'; |
---|
352 | $name_of_tag = array(); |
---|
353 | |
---|
354 | $result = pwg_query($query); |
---|
355 | while ($row = pwg_db_fetch_assoc($result)) |
---|
356 | { |
---|
357 | $name_of_tag[ $row['id'] ] = $row['name']; |
---|
358 | } |
---|
359 | } |
---|
360 | |
---|
361 | $i = 0; |
---|
362 | $first_line = $page['start'] + 1; |
---|
363 | $last_line = $page['start'] + $conf['nb_logs_page']; |
---|
364 | |
---|
365 | $summary['total_filesize'] = 0; |
---|
366 | $summary['guests_IP'] = array(); |
---|
367 | |
---|
368 | foreach ($history_lines as $line) |
---|
369 | { |
---|
370 | // FIXME when we watch the representative of a non image element, it is |
---|
371 | // the not the representative filesize that is counted (as it is |
---|
372 | // unknown) but the non image element filesize. Proposed solution: add |
---|
373 | // #images.representative_filesize and add 'representative' in the |
---|
374 | // choices of #history.image_type. |
---|
375 | |
---|
376 | if (isset($line['image_type'])) |
---|
377 | { |
---|
378 | if ($line['image_type'] == 'high') |
---|
379 | { |
---|
380 | if (isset($high_filesize_of_image[$line['image_id']])) |
---|
381 | { |
---|
382 | $summary['total_filesize']+= |
---|
383 | $high_filesize_of_image[$line['image_id']]; |
---|
384 | } |
---|
385 | } |
---|
386 | else |
---|
387 | { |
---|
388 | if (isset($filesize_of_image[$line['image_id']])) |
---|
389 | { |
---|
390 | $summary['total_filesize']+= |
---|
391 | $filesize_of_image[$line['image_id']]; |
---|
392 | } |
---|
393 | } |
---|
394 | } |
---|
395 | |
---|
396 | if ($line['user_id'] == $conf['guest_id']) |
---|
397 | { |
---|
398 | if (!isset($summary['guests_IP'][ $line['IP'] ])) |
---|
399 | { |
---|
400 | $summary['guests_IP'][ $line['IP'] ] = 0; |
---|
401 | } |
---|
402 | |
---|
403 | $summary['guests_IP'][ $line['IP'] ]++; |
---|
404 | } |
---|
405 | |
---|
406 | $i++; |
---|
407 | |
---|
408 | if ($i < $first_line or $i > $last_line) |
---|
409 | { |
---|
410 | continue; |
---|
411 | } |
---|
412 | |
---|
413 | $user_string = ''; |
---|
414 | if (isset($username_of[$line['user_id']])) |
---|
415 | { |
---|
416 | $user_string.= $username_of[$line['user_id']]; |
---|
417 | } |
---|
418 | else |
---|
419 | { |
---|
420 | $user_string.= $line['user_id']; |
---|
421 | } |
---|
422 | $user_string.= ' <a href="'; |
---|
423 | $user_string.= PHPWG_ROOT_PATH.'admin.php?page=history'; |
---|
424 | $user_string.= '&search_id='.$page['search_id']; |
---|
425 | $user_string.= '&user_id='.$line['user_id']; |
---|
426 | $user_string.= '">+</a>'; |
---|
427 | |
---|
428 | $tags_string = ''; |
---|
429 | if (isset($line['tag_ids'])) |
---|
430 | { |
---|
431 | $tags_string = preg_replace( |
---|
432 | '/(\d+)/e', |
---|
433 | '$name_of_tag["$1"]', |
---|
434 | str_replace( |
---|
435 | ',', |
---|
436 | ', ', |
---|
437 | $line['tag_ids'] |
---|
438 | ) |
---|
439 | ); |
---|
440 | } |
---|
441 | |
---|
442 | $image_string = ''; |
---|
443 | if (isset($line['image_id'])) |
---|
444 | { |
---|
445 | $picture_url = make_picture_url( |
---|
446 | array( |
---|
447 | 'image_id' => $line['image_id'], |
---|
448 | ) |
---|
449 | ); |
---|
450 | |
---|
451 | $element = array( |
---|
452 | 'id' => $line['image_id'], |
---|
453 | 'file' => $file_of_image[$line['image_id']], |
---|
454 | 'path' => $path_of_image[$line['image_id']], |
---|
455 | 'tn_ext' => $tn_ext_of_image[$line['image_id']], |
---|
456 | ); |
---|
457 | |
---|
458 | $image_title = '('.$line['image_id'].')'; |
---|
459 | |
---|
460 | if (isset($label_of_image[$line['image_id']])) |
---|
461 | { |
---|
462 | $image_title.= ' '.$label_of_image[$line['image_id']]; |
---|
463 | } |
---|
464 | else |
---|
465 | { |
---|
466 | $image_title.= ' unknown filename'; |
---|
467 | } |
---|
468 | |
---|
469 | $image_string = ''; |
---|
470 | |
---|
471 | switch ($page['search']['fields']['display_thumbnail']) |
---|
472 | { |
---|
473 | case 'no_display_thumbnail': |
---|
474 | { |
---|
475 | $image_string= '<a href="'.$picture_url.'">'.$image_title.'</a>'; |
---|
476 | break; |
---|
477 | } |
---|
478 | case 'display_thumbnail_classic': |
---|
479 | { |
---|
480 | $image_string = |
---|
481 | '<a class="thumbnail" href="'.$picture_url.'">' |
---|
482 | .'<span><img src="'.get_thumbnail_url($element) |
---|
483 | .'" alt="'.$image_title.'" title="'.$image_title.'">' |
---|
484 | .'</span></a>'; |
---|
485 | break; |
---|
486 | } |
---|
487 | case 'display_thumbnail_hoverbox': |
---|
488 | { |
---|
489 | $image_string = |
---|
490 | '<a class="over" href="'.$picture_url.'">' |
---|
491 | .'<span><img src="'.get_thumbnail_url($element) |
---|
492 | .'" alt="'.$image_title.'" title="'.$image_title.'">' |
---|
493 | .'</span>'.$image_title.'</a>'; |
---|
494 | break; |
---|
495 | } |
---|
496 | } |
---|
497 | } |
---|
498 | |
---|
499 | $template->append( |
---|
500 | 'search_results', |
---|
501 | array( |
---|
502 | 'DATE' => $line['date'], |
---|
503 | 'TIME' => $line['time'], |
---|
504 | 'USER' => $user_string, |
---|
505 | 'IP' => $line['IP'], |
---|
506 | 'IMAGE' => $image_string, |
---|
507 | 'TYPE' => $line['image_type'], |
---|
508 | 'SECTION' => $line['section'], |
---|
509 | 'CATEGORY' => isset($line['category_id']) |
---|
510 | ? ( isset($name_of_category[$line['category_id']]) |
---|
511 | ? $name_of_category[$line['category_id']] |
---|
512 | : 'deleted '.$line['category_id'] ) |
---|
513 | : '', |
---|
514 | 'TAGS' => $tags_string, |
---|
515 | ) |
---|
516 | ); |
---|
517 | } |
---|
518 | |
---|
519 | $summary['nb_guests'] = 0; |
---|
520 | if (count(array_keys($summary['guests_IP'])) > 0) |
---|
521 | { |
---|
522 | $summary['nb_guests'] = count(array_keys($summary['guests_IP'])); |
---|
523 | |
---|
524 | // we delete the "guest" from the $username_of hash so that it is |
---|
525 | // avoided in next steps |
---|
526 | unset($username_of[ $conf['guest_id'] ]); |
---|
527 | } |
---|
528 | |
---|
529 | $summary['nb_members'] = count($username_of); |
---|
530 | |
---|
531 | $member_strings = array(); |
---|
532 | foreach ($username_of as $user_id => $user_name) |
---|
533 | { |
---|
534 | $member_string = $user_name.' <a href="'; |
---|
535 | $member_string.= get_root_url().'admin.php?page=history'; |
---|
536 | $member_string.= '&search_id='.$page['search_id']; |
---|
537 | $member_string.= '&user_id='.$user_id; |
---|
538 | $member_string.= '">+</a>'; |
---|
539 | |
---|
540 | $member_strings[] = $member_string; |
---|
541 | } |
---|
542 | |
---|
543 | $template->assign( |
---|
544 | 'search_summary', |
---|
545 | array( |
---|
546 | 'NB_LINES' => l10n_dec( |
---|
547 | '%d line filtered', '%d lines filtered', |
---|
548 | $page['nb_lines'] |
---|
549 | ), |
---|
550 | 'FILESIZE' => $summary['total_filesize'].' KB', |
---|
551 | 'USERS' => l10n_dec( |
---|
552 | '%d user', '%d users', |
---|
553 | $summary['nb_members'] + $summary['nb_guests'] |
---|
554 | ), |
---|
555 | 'MEMBERS' => sprintf( |
---|
556 | l10n_dec('%d member', '%d members', $summary['nb_members']).': %s', |
---|
557 | implode( |
---|
558 | ', ', |
---|
559 | $member_strings |
---|
560 | ) |
---|
561 | ), |
---|
562 | 'GUESTS' => l10n_dec( |
---|
563 | '%d guest', '%d guests', |
---|
564 | $summary['nb_guests'] |
---|
565 | ), |
---|
566 | ) |
---|
567 | ); |
---|
568 | } |
---|
569 | |
---|
570 | // +-----------------------------------------------------------------------+ |
---|
571 | // | navigation bar | |
---|
572 | // +-----------------------------------------------------------------------+ |
---|
573 | |
---|
574 | if (isset($page['search_id'])) |
---|
575 | { |
---|
576 | $navbar = create_navigation_bar( |
---|
577 | get_root_url().'admin.php'.get_query_string_diff(array('start')), |
---|
578 | $page['nb_lines'], |
---|
579 | $page['start'], |
---|
580 | $conf['nb_logs_page'] |
---|
581 | ); |
---|
582 | |
---|
583 | $template->assign('navbar', $navbar); |
---|
584 | } |
---|
585 | |
---|
586 | // +-----------------------------------------------------------------------+ |
---|
587 | // | filter form | |
---|
588 | // +-----------------------------------------------------------------------+ |
---|
589 | |
---|
590 | $form = array(); |
---|
591 | |
---|
592 | if (isset($page['search'])) |
---|
593 | { |
---|
594 | if (isset($page['search']['fields']['date-after'])) |
---|
595 | { |
---|
596 | $tokens = explode('-', $page['search']['fields']['date-after']); |
---|
597 | |
---|
598 | $form['start_year'] = (int)$tokens[0]; |
---|
599 | $form['start_month'] = (int)$tokens[1]; |
---|
600 | $form['start_day'] = (int)$tokens[2]; |
---|
601 | } |
---|
602 | |
---|
603 | if (isset($page['search']['fields']['date-before'])) |
---|
604 | { |
---|
605 | $tokens = explode('-', $page['search']['fields']['date-before']); |
---|
606 | |
---|
607 | $form['end_year'] = (int)$tokens[0]; |
---|
608 | $form['end_month'] = (int)$tokens[1]; |
---|
609 | $form['end_day'] = (int)$tokens[2]; |
---|
610 | } |
---|
611 | |
---|
612 | $form['types'] = $page['search']['fields']['types']; |
---|
613 | |
---|
614 | if (isset($page['search']['fields']['user'])) |
---|
615 | { |
---|
616 | $form['user'] = $page['search']['fields']['user']; |
---|
617 | } |
---|
618 | else |
---|
619 | { |
---|
620 | $form['user'] = null; |
---|
621 | } |
---|
622 | |
---|
623 | $form['image_id'] = @$page['search']['fields']['image_id']; |
---|
624 | $form['filename'] = @$page['search']['fields']['filename']; |
---|
625 | |
---|
626 | $form['display_thumbnail'] = @$page['search']['fields']['display_thumbnail']; |
---|
627 | } |
---|
628 | else |
---|
629 | { |
---|
630 | // by default, at page load, we want the selected date to be the current |
---|
631 | // date |
---|
632 | $form['start_year'] = $form['end_year'] = date('Y'); |
---|
633 | $form['start_month'] = $form['end_month'] = date('n'); |
---|
634 | $form['start_day'] = $form['end_day'] = date('j'); |
---|
635 | $form['types'] = $types; |
---|
636 | // Hoverbox by default |
---|
637 | $form['display_thumbnail'] = |
---|
638 | pwg_get_cookie_var('display_thumbnail', 'no_display_thumbnail'); |
---|
639 | } |
---|
640 | |
---|
641 | |
---|
642 | $month_list = $lang['month']; |
---|
643 | $month_list[0]='------------'; |
---|
644 | ksort($month_list); |
---|
645 | |
---|
646 | $template->assign( |
---|
647 | array( |
---|
648 | 'IMAGE_ID' => @$form['image_id'], |
---|
649 | 'FILENAME' => @$form['filename'], |
---|
650 | |
---|
651 | 'month_list' => $month_list, |
---|
652 | |
---|
653 | 'START_DAY_SELECTED' => @$form['start_day'], |
---|
654 | 'START_MONTH_SELECTED' => @$form['start_month'], |
---|
655 | 'START_YEAR' => @$form['start_year'], |
---|
656 | |
---|
657 | 'END_DAY_SELECTED' => @$form['end_day'], |
---|
658 | 'END_MONTH_SELECTED' => @$form['end_month'], |
---|
659 | 'END_YEAR' => @$form['end_year'], |
---|
660 | ) |
---|
661 | ); |
---|
662 | |
---|
663 | $template->assign( |
---|
664 | array( |
---|
665 | 'type_option_values' => $types, |
---|
666 | 'type_option_selected' => $form['types'] |
---|
667 | ) |
---|
668 | ); |
---|
669 | |
---|
670 | |
---|
671 | $query = ' |
---|
672 | SELECT |
---|
673 | '.$conf['user_fields']['id'].' AS id, |
---|
674 | '.$conf['user_fields']['username'].' AS username |
---|
675 | FROM '.USERS_TABLE.' |
---|
676 | ORDER BY username ASC |
---|
677 | ;'; |
---|
678 | $template->assign( |
---|
679 | array( |
---|
680 | 'user_options' => simple_hash_from_query($query, 'id','username'), |
---|
681 | 'user_options_selected' => array(@$form['user']) |
---|
682 | ) |
---|
683 | ); |
---|
684 | |
---|
685 | $template->assign('display_thumbnails', $display_thumbnails); |
---|
686 | $template->assign('display_thumbnail_selected', $form['display_thumbnail']); |
---|
687 | |
---|
688 | // +-----------------------------------------------------------------------+ |
---|
689 | // | html code display | |
---|
690 | // +-----------------------------------------------------------------------+ |
---|
691 | |
---|
692 | $template->assign_var_from_handle('ADMIN_CONTENT', 'history'); |
---|
693 | ?> |
---|