| 421 | | if ($app->{searchparam}{SearchCutoff} && |
|---|
| 422 | | $app->{searchparam}{SearchCutoff} != 9999999) { |
|---|
| 423 | | my @ago = MT::Util::offset_time_list(time - 3600 * 24 * |
|---|
| 424 | | $app->{searchparam}{SearchCutoff}); |
|---|
| 425 | | my $ago = sprintf "%04d%02d%02d%02d%02d%02d", |
|---|
| 426 | | $ago[5]+1900, $ago[4]+1, @ago[3,2,1,0]; |
|---|
| 427 | | $terms{created_on} = [ $ago ]; |
|---|
| | 421 | # Override SearchCutoff if If-Modified-Since header is present |
|---|
| | 422 | if (my $mod_since = $app->get_header('If-Modified-Since')) { |
|---|
| | 423 | my $tz_offset = 15; # Start with maximum possible offset to UTC |
|---|
| | 424 | my $blog_selected; |
|---|
| | 425 | my $iter; |
|---|
| | 426 | if ($app->{searchparam}{IncludeBlogs}) { |
|---|
| | 427 | $iter = MT::Blog->load_iter({ id => [ keys %{ $app->{searchparam}{IncludeBlogs} }] }); |
|---|
| | 428 | } else { |
|---|
| | 429 | $iter = MT::Blog->load_iter; |
|---|
| | 430 | } |
|---|
| | 431 | while (my $blog = $iter->()) { |
|---|
| | 432 | my $blog_offset = $blog->server_offset ? |
|---|
| | 433 | $blog->server_offset : 0; |
|---|
| | 434 | if ($blog_offset < $tz_offset) { |
|---|
| | 435 | $tz_offset = $blog_offset; |
|---|
| | 436 | $blog_selected = $blog; |
|---|
| | 437 | } |
|---|
| | 438 | } |
|---|
| | 439 | $mod_since = epoch2ts($blog_selected, str2time($mod_since)); |
|---|
| | 440 | $terms{created_on} = [ $mod_since ]; |
|---|
| | 442 | } else { |
|---|
| | 443 | if ($app->{searchparam}{SearchCutoff} && |
|---|
| | 444 | $app->{searchparam}{SearchCutoff} != 9999999) { |
|---|
| | 445 | my @ago = MT::Util::offset_time_list(time - 3600 * 24 * |
|---|
| | 446 | $app->{searchparam}{SearchCutoff}); |
|---|
| | 447 | my $ago = sprintf "%04d%02d%02d%02d%02d%02d", |
|---|
| | 448 | $ago[5]+1900, $ago[4]+1, @ago[3,2,1,0]; |
|---|
| | 449 | $terms{created_on} = [ $ago ]; |
|---|
| | 450 | $args{range} = { created_on => 1 }; |
|---|
| | 451 | } |
|---|
| 469 | | if ($app->{searchparam}{SearchCutoff} && |
|---|
| 470 | | $app->{searchparam}{SearchCutoff} != 9999999) { |
|---|
| 471 | | my @ago = MT::Util::offset_time_list(time - 3600 * 24 * |
|---|
| 472 | | $app->{searchparam}{SearchCutoff}); |
|---|
| 473 | | my $ago = sprintf "%04d%02d%02d%02d%02d%02d", |
|---|
| 474 | | $ago[5]+1900, $ago[4]+1, @ago[3,2,1,0]; |
|---|
| 475 | | $terms{created_on} = [ $ago ]; |
|---|
| | 492 | # Override SearchCutoff if If-Modified-Since header is present |
|---|
| | 493 | if (my $mod_since = $app->get_header('If-Modified-Since')) { |
|---|
| | 494 | my $tz_offset = 15; # Start with maximum possible offset to UTC |
|---|
| | 495 | my $blog_selected; |
|---|
| | 496 | my $iter; |
|---|
| | 497 | if ($app->{searchparam}{IncludeBlogs}) { |
|---|
| | 498 | $iter = MT::Blog->load_iter({ id => [ keys %{ $app->{searchparam}{IncludeBlogs} }] }); |
|---|
| | 499 | } else { |
|---|
| | 500 | $iter = MT::Blog->load_iter; |
|---|
| | 501 | } |
|---|
| | 502 | while (my $blog = $iter->()) { |
|---|
| | 503 | my $blog_offset = $blog->server_offset ? |
|---|
| | 504 | $blog->server_offset : 0; |
|---|
| | 505 | if ($blog_offset < $tz_offset) { |
|---|
| | 506 | $tz_offset = $blog_offset; |
|---|
| | 507 | $blog_selected = $blog; |
|---|
| | 508 | } |
|---|
| | 509 | } |
|---|
| | 510 | $mod_since = epoch2ts($blog_selected, str2time($mod_since)); |
|---|
| | 511 | $terms{created_on} = [ $mod_since ]; |
|---|
| | 513 | } else { |
|---|
| | 514 | if ($app->{searchparam}{SearchCutoff} && |
|---|
| | 515 | $app->{searchparam}{SearchCutoff} != 9999999) { |
|---|
| | 516 | my @ago = MT::Util::offset_time_list(time - 3600 * 24 * |
|---|
| | 517 | $app->{searchparam}{SearchCutoff}); |
|---|
| | 518 | my $ago = sprintf "%04d%02d%02d%02d%02d%02d", |
|---|
| | 519 | $ago[5]+1900, $ago[4]+1, @ago[3,2,1,0]; |
|---|
| | 520 | $terms{created_on} = [ $ago ]; |
|---|
| | 521 | $args{range} = { created_on => 1 }; |
|---|
| | 522 | } |
|---|