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