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