[1727] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[19703] | 5 | // | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | |
---|
[2297] | 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 | // +-----------------------------------------------------------------------+ |
---|
[1727] | 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'); |
---|
[1881] | 42 | include_once(PHPWG_ROOT_PATH.'admin/include/functions_history.inc.php'); |
---|
[1727] | 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 | |
---|
[1844] | 53 | $types = array('none', 'picture', 'high', 'other'); |
---|
| 54 | |
---|
[5576] | 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 | |
---|
[1727] | 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 | |
---|
[1892] | 70 | $page['errors'] = array(); |
---|
[1727] | 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 | |
---|
[2157] | 96 | if (empty($_POST['types'])) |
---|
| 97 | { |
---|
| 98 | $search['fields']['types'] = $types; |
---|
| 99 | } |
---|
| 100 | else |
---|
| 101 | { |
---|
| 102 | $search['fields']['types'] = $_POST['types']; |
---|
| 103 | } |
---|
[1890] | 104 | |
---|
| 105 | $search['fields']['user'] = $_POST['user']; |
---|
[1892] | 106 | |
---|
| 107 | if (!empty($_POST['image_id'])) |
---|
| 108 | { |
---|
| 109 | $search['fields']['image_id'] = intval($_POST['image_id']); |
---|
| 110 | } |
---|
[2245] | 111 | |
---|
[1892] | 112 | if (!empty($_POST['filename'])) |
---|
| 113 | { |
---|
| 114 | $search['fields']['filename'] = str_replace( |
---|
| 115 | '*', |
---|
| 116 | '%', |
---|
[4325] | 117 | pwg_db_real_escape_string($_POST['filename']) |
---|
[1892] | 118 | ); |
---|
| 119 | } |
---|
| 120 | |
---|
[14688] | 121 | if (!empty($_POST['ip'])) |
---|
| 122 | { |
---|
| 123 | $search['fields']['ip'] = str_replace( |
---|
| 124 | '*', |
---|
| 125 | '%', |
---|
| 126 | pwg_db_real_escape_string($_POST['ip']) |
---|
| 127 | ); |
---|
| 128 | } |
---|
| 129 | |
---|
[1992] | 130 | $search['fields']['display_thumbnail'] = $_POST['display_thumbnail']; |
---|
| 131 | // Display choise are also save to one cookie |
---|
[5576] | 132 | if (!empty($_POST['display_thumbnail']) |
---|
| 133 | and isset($display_thumbnails[$_POST['display_thumbnail']])) |
---|
| 134 | { |
---|
| 135 | $cookie_val = $_POST['display_thumbnail']; |
---|
| 136 | } |
---|
| 137 | else |
---|
| 138 | { |
---|
| 139 | $cookie_val = null; |
---|
| 140 | } |
---|
[14688] | 141 | |
---|
[5576] | 142 | pwg_set_cookie_var('display_thumbnail', $cookie_val, strtotime('+1 month') ); |
---|
[1992] | 143 | |
---|
[1892] | 144 | // TODO manage inconsistency of having $_POST['image_id'] and |
---|
| 145 | // $_POST['filename'] simultaneously |
---|
[2245] | 146 | |
---|
[1727] | 147 | if (!empty($search)) |
---|
| 148 | { |
---|
| 149 | // register search rules in database, then they will be available on |
---|
| 150 | // thumbnails page and picture page. |
---|
| 151 | $query =' |
---|
| 152 | INSERT INTO '.SEARCH_TABLE.' |
---|
| 153 | (rules) |
---|
| 154 | VALUES |
---|
| 155 | (\''.serialize($search).'\') |
---|
| 156 | ;'; |
---|
| 157 | pwg_query($query); |
---|
| 158 | |
---|
[4892] | 159 | $search_id = pwg_db_insert_id(SEARCH_TABLE); |
---|
[2245] | 160 | |
---|
[1727] | 161 | redirect( |
---|
| 162 | PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id |
---|
| 163 | ); |
---|
| 164 | } |
---|
| 165 | else |
---|
| 166 | { |
---|
[25018] | 167 | $page['errors'][] = l10n('Empty query. No criteria has been entered.'); |
---|
[1727] | 168 | } |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | // +-----------------------------------------------------------------------+ |
---|
| 172 | // | template init | |
---|
| 173 | // +-----------------------------------------------------------------------+ |
---|
| 174 | |
---|
[2530] | 175 | $template->set_filename('history', 'history.tpl'); |
---|
[1727] | 176 | |
---|
[1881] | 177 | // TabSheet initialization |
---|
| 178 | history_tabsheet(); |
---|
| 179 | |
---|
[2245] | 180 | $template->assign( |
---|
[1727] | 181 | array( |
---|
[5920] | 182 | 'U_HELP' => get_root_url().'admin/popuphelp.php?page=history', |
---|
[2245] | 183 | 'F_ACTION' => get_root_url().'admin.php?page=history' |
---|
[1727] | 184 | ) |
---|
| 185 | ); |
---|
| 186 | |
---|
| 187 | // +-----------------------------------------------------------------------+ |
---|
| 188 | // | history lines | |
---|
| 189 | // +-----------------------------------------------------------------------+ |
---|
| 190 | |
---|
| 191 | if (isset($_GET['search_id']) |
---|
| 192 | and $page['search_id'] = (int)$_GET['search_id']) |
---|
| 193 | { |
---|
| 194 | // what are the lines to display in reality ? |
---|
| 195 | $query = ' |
---|
| 196 | SELECT rules |
---|
| 197 | FROM '.SEARCH_TABLE.' |
---|
| 198 | WHERE id = '.$page['search_id'].' |
---|
| 199 | ;'; |
---|
[4325] | 200 | list($serialized_rules) = pwg_db_fetch_row(pwg_query($query)); |
---|
[1727] | 201 | |
---|
| 202 | $page['search'] = unserialize($serialized_rules); |
---|
| 203 | |
---|
[1890] | 204 | if (isset($_GET['user_id'])) |
---|
| 205 | { |
---|
| 206 | if (!is_numeric($_GET['user_id'])) |
---|
| 207 | { |
---|
| 208 | die('user_id GET parameter must be an integer value'); |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | $page['search']['fields']['user'] = $_GET['user_id']; |
---|
[2157] | 212 | |
---|
[1890] | 213 | $query =' |
---|
| 214 | INSERT INTO '.SEARCH_TABLE.' |
---|
| 215 | (rules) |
---|
| 216 | VALUES |
---|
| 217 | (\''.serialize($page['search']).'\') |
---|
| 218 | ;'; |
---|
| 219 | pwg_query($query); |
---|
| 220 | |
---|
[4892] | 221 | $search_id = pwg_db_insert_id(SEARCH_TABLE); |
---|
[2245] | 222 | |
---|
[1890] | 223 | redirect( |
---|
| 224 | PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id |
---|
| 225 | ); |
---|
| 226 | } |
---|
| 227 | |
---|
[2157] | 228 | $data = trigger_event('get_history', array(), $page['search'], $types); |
---|
| 229 | usort($data, 'history_compare'); |
---|
[1727] | 230 | |
---|
[2157] | 231 | $page['nb_lines'] = count($data); |
---|
[1727] | 232 | |
---|
[1883] | 233 | $history_lines = array(); |
---|
| 234 | $user_ids = array(); |
---|
[1929] | 235 | $username_of = array(); |
---|
[1883] | 236 | $category_ids = array(); |
---|
| 237 | $image_ids = array(); |
---|
[14688] | 238 | $has_tags = false; |
---|
[2157] | 239 | |
---|
| 240 | foreach ($data as $row) |
---|
[1727] | 241 | { |
---|
| 242 | $user_ids[$row['user_id']] = 1; |
---|
| 243 | |
---|
| 244 | if (isset($row['category_id'])) |
---|
| 245 | { |
---|
| 246 | $category_ids[$row['category_id']] = 1; |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | if (isset($row['image_id'])) |
---|
| 250 | { |
---|
| 251 | $image_ids[$row['image_id']] = 1; |
---|
| 252 | } |
---|
| 253 | |
---|
[1891] | 254 | if (isset($row['tag_ids'])) |
---|
| 255 | { |
---|
[14688] | 256 | $has_tags = true; |
---|
[1891] | 257 | } |
---|
| 258 | |
---|
[14688] | 259 | $history_lines[] = $row; |
---|
[1727] | 260 | } |
---|
| 261 | |
---|
| 262 | // prepare reference data (users, tags, categories...) |
---|
| 263 | if (count($user_ids) > 0) |
---|
| 264 | { |
---|
| 265 | $query = ' |
---|
| 266 | SELECT '.$conf['user_fields']['id'].' AS id |
---|
| 267 | , '.$conf['user_fields']['username'].' AS username |
---|
| 268 | FROM '.USERS_TABLE.' |
---|
| 269 | WHERE id IN ('.implode(',', array_keys($user_ids)).') |
---|
| 270 | ;'; |
---|
| 271 | $result = pwg_query($query); |
---|
| 272 | |
---|
| 273 | $username_of = array(); |
---|
[4325] | 274 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[1727] | 275 | { |
---|
[4304] | 276 | $username_of[$row['id']] = stripslashes($row['username']); |
---|
[1727] | 277 | } |
---|
| 278 | } |
---|
| 279 | |
---|
| 280 | if (count($category_ids) > 0) |
---|
| 281 | { |
---|
| 282 | $query = ' |
---|
| 283 | SELECT id, uppercats |
---|
| 284 | FROM '.CATEGORIES_TABLE.' |
---|
| 285 | WHERE id IN ('.implode(',', array_keys($category_ids)).') |
---|
| 286 | ;'; |
---|
| 287 | $uppercats_of = simple_hash_from_query($query, 'id', 'uppercats'); |
---|
| 288 | |
---|
| 289 | $name_of_category = array(); |
---|
[2245] | 290 | |
---|
[1727] | 291 | foreach ($uppercats_of as $category_id => $uppercats) |
---|
| 292 | { |
---|
| 293 | $name_of_category[$category_id] = get_cat_display_name_cache( |
---|
| 294 | $uppercats |
---|
| 295 | ); |
---|
| 296 | } |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | if (count($image_ids) > 0) |
---|
| 300 | { |
---|
| 301 | $query = ' |
---|
[1883] | 302 | SELECT |
---|
| 303 | id, |
---|
| 304 | IF(name IS NULL, file, name) AS label, |
---|
| 305 | filesize, |
---|
[1991] | 306 | file, |
---|
| 307 | path, |
---|
[12796] | 308 | representative_ext |
---|
[1727] | 309 | FROM '.IMAGES_TABLE.' |
---|
| 310 | WHERE id IN ('.implode(',', array_keys($image_ids)).') |
---|
| 311 | ;'; |
---|
[1883] | 312 | // $label_of_image = simple_hash_from_query($query, 'id', 'label'); |
---|
| 313 | $label_of_image = array(); |
---|
| 314 | $filesize_of_image = array(); |
---|
[1991] | 315 | $file_of_image = array(); |
---|
| 316 | $path_of_image = array(); |
---|
[12796] | 317 | $representative_ext_of_image = array(); |
---|
[1991] | 318 | |
---|
[1883] | 319 | $result = pwg_query($query); |
---|
[4325] | 320 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[1883] | 321 | { |
---|
| 322 | $label_of_image[ $row['id'] ] = $row['label']; |
---|
| 323 | |
---|
| 324 | if (isset($row['filesize'])) |
---|
| 325 | { |
---|
| 326 | $filesize_of_image[ $row['id'] ] = $row['filesize']; |
---|
| 327 | } |
---|
| 328 | |
---|
[1991] | 329 | $file_of_image[ $row['id'] ] = $row['file']; |
---|
| 330 | $path_of_image[ $row['id'] ] = $row['path']; |
---|
[12796] | 331 | $representative_ext_of_image[ $row['id'] ] = $row['representative_ext']; |
---|
[1883] | 332 | } |
---|
[1727] | 333 | } |
---|
[1891] | 334 | |
---|
[14688] | 335 | if ($has_tags > 0) |
---|
[1891] | 336 | { |
---|
| 337 | $query = ' |
---|
| 338 | SELECT |
---|
| 339 | id, |
---|
[23151] | 340 | name, url_name |
---|
[14688] | 341 | FROM '.TAGS_TABLE; |
---|
[23151] | 342 | $name_of_tag = array(); |
---|
| 343 | $result = pwg_query($query); |
---|
| 344 | while ($row=pwg_db_fetch_assoc($result)) |
---|
| 345 | { |
---|
| 346 | $name_of_tag[ $row['id'] ] = '<a href="'.make_index_url( array('tags'=>array($row))).'">'.trigger_event("render_tag_name", $row['name']).'</a>'; |
---|
| 347 | } |
---|
[1891] | 348 | } |
---|
[2245] | 349 | |
---|
[1727] | 350 | $i = 0; |
---|
[1883] | 351 | $first_line = $page['start'] + 1; |
---|
| 352 | $last_line = $page['start'] + $conf['nb_logs_page']; |
---|
[1727] | 353 | |
---|
[1893] | 354 | $summary['total_filesize'] = 0; |
---|
| 355 | $summary['guests_IP'] = array(); |
---|
[1883] | 356 | |
---|
[1727] | 357 | foreach ($history_lines as $line) |
---|
| 358 | { |
---|
[16282] | 359 | if (isset($line['image_type']) and $line['image_type'] == 'high') |
---|
[1883] | 360 | { |
---|
[16282] | 361 | if (isset($filesize_of_image[$line['image_id']])) |
---|
[1883] | 362 | { |
---|
[16282] | 363 | $summary['total_filesize'] += $filesize_of_image[$line['image_id']]; |
---|
[1883] | 364 | } |
---|
| 365 | } |
---|
[1893] | 366 | |
---|
| 367 | if ($line['user_id'] == $conf['guest_id']) |
---|
| 368 | { |
---|
| 369 | if (!isset($summary['guests_IP'][ $line['IP'] ])) |
---|
| 370 | { |
---|
| 371 | $summary['guests_IP'][ $line['IP'] ] = 0; |
---|
| 372 | } |
---|
[2245] | 373 | |
---|
[1893] | 374 | $summary['guests_IP'][ $line['IP'] ]++; |
---|
| 375 | } |
---|
[2245] | 376 | |
---|
[1883] | 377 | $i++; |
---|
[2245] | 378 | |
---|
[1883] | 379 | if ($i < $first_line or $i > $last_line) |
---|
| 380 | { |
---|
| 381 | continue; |
---|
| 382 | } |
---|
[1890] | 383 | |
---|
| 384 | $user_string = ''; |
---|
| 385 | if (isset($username_of[$line['user_id']])) |
---|
| 386 | { |
---|
| 387 | $user_string.= $username_of[$line['user_id']]; |
---|
| 388 | } |
---|
| 389 | else |
---|
| 390 | { |
---|
| 391 | $user_string.= $line['user_id']; |
---|
| 392 | } |
---|
| 393 | $user_string.= ' <a href="'; |
---|
| 394 | $user_string.= PHPWG_ROOT_PATH.'admin.php?page=history'; |
---|
| 395 | $user_string.= '&search_id='.$page['search_id']; |
---|
| 396 | $user_string.= '&user_id='.$line['user_id']; |
---|
| 397 | $user_string.= '">+</a>'; |
---|
[1891] | 398 | |
---|
| 399 | $tags_string = ''; |
---|
| 400 | if (isset($line['tag_ids'])) |
---|
| 401 | { |
---|
| 402 | $tags_string = preg_replace( |
---|
| 403 | '/(\d+)/e', |
---|
[23185] | 404 | 'isset($name_of_tag["$1"]) ? $name_of_tag["$1"] : "$1"', |
---|
[1891] | 405 | str_replace( |
---|
| 406 | ',', |
---|
| 407 | ', ', |
---|
| 408 | $line['tag_ids'] |
---|
| 409 | ) |
---|
| 410 | ); |
---|
| 411 | } |
---|
[1896] | 412 | |
---|
| 413 | $image_string = ''; |
---|
| 414 | if (isset($line['image_id'])) |
---|
| 415 | { |
---|
| 416 | $picture_url = make_picture_url( |
---|
| 417 | array( |
---|
| 418 | 'image_id' => $line['image_id'], |
---|
| 419 | ) |
---|
| 420 | ); |
---|
[1992] | 421 | |
---|
[9808] | 422 | if (isset($file_of_image[$line['image_id']])) |
---|
| 423 | { |
---|
| 424 | $element = array( |
---|
| 425 | 'id' => $line['image_id'], |
---|
| 426 | 'file' => $file_of_image[$line['image_id']], |
---|
| 427 | 'path' => $path_of_image[$line['image_id']], |
---|
[12796] | 428 | 'representative_ext' => $representative_ext_of_image[$line['image_id']], |
---|
[9808] | 429 | ); |
---|
| 430 | $thumbnail_display = $page['search']['fields']['display_thumbnail']; |
---|
| 431 | } |
---|
| 432 | else |
---|
| 433 | { |
---|
| 434 | $thumbnail_display = 'no_display_thumbnail'; |
---|
| 435 | } |
---|
[1992] | 436 | |
---|
| 437 | $image_title = '('.$line['image_id'].')'; |
---|
| 438 | |
---|
[1896] | 439 | if (isset($label_of_image[$line['image_id']])) |
---|
| 440 | { |
---|
[1992] | 441 | $image_title.= ' '.$label_of_image[$line['image_id']]; |
---|
[1896] | 442 | } |
---|
| 443 | else |
---|
| 444 | { |
---|
[1992] | 445 | $image_title.= ' unknown filename'; |
---|
[1896] | 446 | } |
---|
[1992] | 447 | |
---|
| 448 | $image_string = ''; |
---|
| 449 | |
---|
[9808] | 450 | switch ($thumbnail_display) |
---|
[1992] | 451 | { |
---|
| 452 | case 'no_display_thumbnail': |
---|
| 453 | { |
---|
| 454 | $image_string= '<a href="'.$picture_url.'">'.$image_title.'</a>'; |
---|
| 455 | break; |
---|
| 456 | } |
---|
| 457 | case 'display_thumbnail_classic': |
---|
| 458 | { |
---|
| 459 | $image_string = |
---|
| 460 | '<a class="thumbnail" href="'.$picture_url.'">' |
---|
[12796] | 461 | .'<span><img src="'.DerivativeImage::thumb_url($element) |
---|
[1992] | 462 | .'" alt="'.$image_title.'" title="'.$image_title.'">' |
---|
| 463 | .'</span></a>'; |
---|
| 464 | break; |
---|
| 465 | } |
---|
| 466 | case 'display_thumbnail_hoverbox': |
---|
| 467 | { |
---|
| 468 | $image_string = |
---|
| 469 | '<a class="over" href="'.$picture_url.'">' |
---|
[12796] | 470 | .'<span><img src="'.DerivativeImage::thumb_url($element) |
---|
[1992] | 471 | .'" alt="'.$image_title.'" title="'.$image_title.'">' |
---|
| 472 | .'</span>'.$image_title.'</a>'; |
---|
| 473 | break; |
---|
| 474 | } |
---|
| 475 | } |
---|
[1896] | 476 | } |
---|
[2245] | 477 | |
---|
| 478 | $template->append( |
---|
| 479 | 'search_results', |
---|
[1727] | 480 | array( |
---|
| 481 | 'DATE' => $line['date'], |
---|
| 482 | 'TIME' => $line['time'], |
---|
[1890] | 483 | 'USER' => $user_string, |
---|
[1727] | 484 | 'IP' => $line['IP'], |
---|
[1896] | 485 | 'IMAGE' => $image_string, |
---|
[1844] | 486 | 'TYPE' => $line['image_type'], |
---|
[1727] | 487 | 'SECTION' => $line['section'], |
---|
| 488 | 'CATEGORY' => isset($line['category_id']) |
---|
[1821] | 489 | ? ( isset($name_of_category[$line['category_id']]) |
---|
| 490 | ? $name_of_category[$line['category_id']] |
---|
| 491 | : 'deleted '.$line['category_id'] ) |
---|
[1727] | 492 | : '', |
---|
[1891] | 493 | 'TAGS' => $tags_string, |
---|
[1727] | 494 | ) |
---|
| 495 | ); |
---|
| 496 | } |
---|
[1883] | 497 | |
---|
[1893] | 498 | $summary['nb_guests'] = 0; |
---|
| 499 | if (count(array_keys($summary['guests_IP'])) > 0) |
---|
| 500 | { |
---|
| 501 | $summary['nb_guests'] = count(array_keys($summary['guests_IP'])); |
---|
| 502 | |
---|
| 503 | // we delete the "guest" from the $username_of hash so that it is |
---|
| 504 | // avoided in next steps |
---|
| 505 | unset($username_of[ $conf['guest_id'] ]); |
---|
| 506 | } |
---|
[2245] | 507 | |
---|
[1893] | 508 | $summary['nb_members'] = count($username_of); |
---|
| 509 | |
---|
| 510 | $member_strings = array(); |
---|
| 511 | foreach ($username_of as $user_id => $user_name) |
---|
| 512 | { |
---|
| 513 | $member_string = $user_name.' <a href="'; |
---|
[2245] | 514 | $member_string.= get_root_url().'admin.php?page=history'; |
---|
[1893] | 515 | $member_string.= '&search_id='.$page['search_id']; |
---|
| 516 | $member_string.= '&user_id='.$user_id; |
---|
| 517 | $member_string.= '">+</a>'; |
---|
| 518 | |
---|
| 519 | $member_strings[] = $member_string; |
---|
| 520 | } |
---|
[2245] | 521 | |
---|
| 522 | $template->assign( |
---|
| 523 | 'search_summary', |
---|
[1883] | 524 | array( |
---|
[1932] | 525 | 'NB_LINES' => l10n_dec( |
---|
| 526 | '%d line filtered', '%d lines filtered', |
---|
[1893] | 527 | $page['nb_lines'] |
---|
| 528 | ), |
---|
[16282] | 529 | 'FILESIZE' => $summary['total_filesize'] != 0 ? ceil($summary['total_filesize']/1024).' MB' : '', |
---|
[1932] | 530 | 'USERS' => l10n_dec( |
---|
| 531 | '%d user', '%d users', |
---|
[1893] | 532 | $summary['nb_members'] + $summary['nb_guests'] |
---|
| 533 | ), |
---|
| 534 | 'MEMBERS' => sprintf( |
---|
[1932] | 535 | l10n_dec('%d member', '%d members', $summary['nb_members']).': %s', |
---|
[25005] | 536 | implode(', ', $member_strings) |
---|
[1893] | 537 | ), |
---|
[1932] | 538 | 'GUESTS' => l10n_dec( |
---|
| 539 | '%d guest', '%d guests', |
---|
[1893] | 540 | $summary['nb_guests'] |
---|
| 541 | ), |
---|
[1883] | 542 | ) |
---|
| 543 | ); |
---|
[1727] | 544 | } |
---|
| 545 | |
---|
| 546 | // +-----------------------------------------------------------------------+ |
---|
| 547 | // | navigation bar | |
---|
| 548 | // +-----------------------------------------------------------------------+ |
---|
| 549 | |
---|
| 550 | if (isset($page['search_id'])) |
---|
| 551 | { |
---|
| 552 | $navbar = create_navigation_bar( |
---|
[2245] | 553 | get_root_url().'admin.php'.get_query_string_diff(array('start')), |
---|
[1727] | 554 | $page['nb_lines'], |
---|
| 555 | $page['start'], |
---|
| 556 | $conf['nb_logs_page'] |
---|
| 557 | ); |
---|
| 558 | |
---|
[3172] | 559 | $template->assign('navbar', $navbar); |
---|
[1727] | 560 | } |
---|
| 561 | |
---|
| 562 | // +-----------------------------------------------------------------------+ |
---|
| 563 | // | filter form | |
---|
| 564 | // +-----------------------------------------------------------------------+ |
---|
| 565 | |
---|
| 566 | $form = array(); |
---|
| 567 | |
---|
| 568 | if (isset($page['search'])) |
---|
| 569 | { |
---|
| 570 | if (isset($page['search']['fields']['date-after'])) |
---|
| 571 | { |
---|
| 572 | $tokens = explode('-', $page['search']['fields']['date-after']); |
---|
[2245] | 573 | |
---|
[1727] | 574 | $form['start_year'] = (int)$tokens[0]; |
---|
| 575 | $form['start_month'] = (int)$tokens[1]; |
---|
| 576 | $form['start_day'] = (int)$tokens[2]; |
---|
| 577 | } |
---|
| 578 | |
---|
| 579 | if (isset($page['search']['fields']['date-before'])) |
---|
| 580 | { |
---|
| 581 | $tokens = explode('-', $page['search']['fields']['date-before']); |
---|
[1817] | 582 | |
---|
| 583 | $form['end_year'] = (int)$tokens[0]; |
---|
| 584 | $form['end_month'] = (int)$tokens[1]; |
---|
| 585 | $form['end_day'] = (int)$tokens[2]; |
---|
[1727] | 586 | } |
---|
[1817] | 587 | |
---|
[1844] | 588 | $form['types'] = $page['search']['fields']['types']; |
---|
[1890] | 589 | |
---|
| 590 | if (isset($page['search']['fields']['user'])) |
---|
| 591 | { |
---|
| 592 | $form['user'] = $page['search']['fields']['user']; |
---|
| 593 | } |
---|
| 594 | else |
---|
| 595 | { |
---|
| 596 | $form['user'] = null; |
---|
| 597 | } |
---|
[1892] | 598 | |
---|
| 599 | $form['image_id'] = @$page['search']['fields']['image_id']; |
---|
| 600 | $form['filename'] = @$page['search']['fields']['filename']; |
---|
[14688] | 601 | $form['ip'] = @$page['search']['fields']['ip']; |
---|
[1992] | 602 | |
---|
| 603 | $form['display_thumbnail'] = @$page['search']['fields']['display_thumbnail']; |
---|
[1727] | 604 | } |
---|
| 605 | else |
---|
| 606 | { |
---|
| 607 | // by default, at page load, we want the selected date to be the current |
---|
| 608 | // date |
---|
| 609 | $form['start_year'] = $form['end_year'] = date('Y'); |
---|
| 610 | $form['start_month'] = $form['end_month'] = date('n'); |
---|
| 611 | $form['start_day'] = $form['end_day'] = date('j'); |
---|
[1844] | 612 | $form['types'] = $types; |
---|
[1992] | 613 | // Hoverbox by default |
---|
| 614 | $form['display_thumbnail'] = |
---|
[5576] | 615 | pwg_get_cookie_var('display_thumbnail', 'no_display_thumbnail'); |
---|
[1727] | 616 | } |
---|
| 617 | |
---|
| 618 | |
---|
[2245] | 619 | $month_list = $lang['month']; |
---|
| 620 | $month_list[0]='------------'; |
---|
| 621 | ksort($month_list); |
---|
| 622 | |
---|
| 623 | $template->assign( |
---|
[1727] | 624 | array( |
---|
[2245] | 625 | 'IMAGE_ID' => @$form['image_id'], |
---|
| 626 | 'FILENAME' => @$form['filename'], |
---|
[14688] | 627 | 'IP' => @$form['ip'], |
---|
[2245] | 628 | |
---|
| 629 | 'month_list' => $month_list, |
---|
| 630 | |
---|
| 631 | 'START_DAY_SELECTED' => @$form['start_day'], |
---|
| 632 | 'START_MONTH_SELECTED' => @$form['start_month'], |
---|
[1727] | 633 | 'START_YEAR' => @$form['start_year'], |
---|
[2245] | 634 | |
---|
| 635 | 'END_DAY_SELECTED' => @$form['end_day'], |
---|
| 636 | 'END_MONTH_SELECTED' => @$form['end_month'], |
---|
[1727] | 637 | 'END_YEAR' => @$form['end_year'], |
---|
| 638 | ) |
---|
| 639 | ); |
---|
[1817] | 640 | |
---|
[2245] | 641 | $template->assign( |
---|
[1844] | 642 | array( |
---|
[2245] | 643 | 'type_option_values' => $types, |
---|
| 644 | 'type_option_selected' => $form['types'] |
---|
[1890] | 645 | ) |
---|
| 646 | ); |
---|
| 647 | |
---|
[2245] | 648 | |
---|
[1890] | 649 | $query = ' |
---|
| 650 | SELECT |
---|
| 651 | '.$conf['user_fields']['id'].' AS id, |
---|
| 652 | '.$conf['user_fields']['username'].' AS username |
---|
| 653 | FROM '.USERS_TABLE.' |
---|
| 654 | ORDER BY username ASC |
---|
| 655 | ;'; |
---|
[2245] | 656 | $template->assign( |
---|
| 657 | array( |
---|
| 658 | 'user_options' => simple_hash_from_query($query, 'id','username'), |
---|
| 659 | 'user_options_selected' => array(@$form['user']) |
---|
| 660 | ) |
---|
| 661 | ); |
---|
[1890] | 662 | |
---|
[5576] | 663 | $template->assign('display_thumbnails', $display_thumbnails); |
---|
| 664 | $template->assign('display_thumbnail_selected', $form['display_thumbnail']); |
---|
[1890] | 665 | |
---|
[1727] | 666 | // +-----------------------------------------------------------------------+ |
---|
| 667 | // | html code display | |
---|
| 668 | // +-----------------------------------------------------------------------+ |
---|
| 669 | |
---|
| 670 | $template->assign_var_from_handle('ADMIN_CONTENT', 'history'); |
---|
[2245] | 671 | ?> |
---|