*** MTPaginate2.pl 2006-12-21 15:05:17.000000000 +0900
--- MTPaginate2chg.pl 2006-12-21 15:04:52.000000000 +0900
***************
*** 12,24 ****
#
# Copyright (c) 2004-2005 Stepan Riha
# http://www.nonplus.net
# ---------------------------------------------------------------------------
use strict;
! package MTPlugin::Nonplus::MTPaginate;
use MT::Template::Context;
! use MT::Util qw( remove_html decode_html encode_html );
use vars qw( $VERSION );
our $VERSION = '1.26';
--- 12,33 ----
#
# Copyright (c) 2004-2005 Stepan Riha
# http://www.nonplus.net
+ #
+ # + Patch1.01 For Dynamic Parameter To Static(Fake!) URI.
+ # 2006/12/15 By debizoh.
+ #
+ # Remark!!
+ # Distribution of this module is based on distribution restrictions of original module development origin.
+ # No matter what problem may occur by use of a patch, there is no guarantee which copes with it.
+ # Moreover, don't ask original development origin about the action after this patch application.
+ # Please give me use of this patch by accountability.
# ---------------------------------------------------------------------------
use strict;
! package MTPlugin::Nonplus::MTPaginate2;
use MT::Template::Context;
! use MT::Util qw( remove_html decode_html encode_html archive_file_for );
use vars qw( $VERSION );
our $VERSION = '1.26';
***************
*** 26,32 ****
## Register MT handlers
MT::Template::Context->add_tag(PaginateVersion => sub { $VERSION } );
! MT::Template::Context->add_container_tag(Paginate => \&MTPaginate );
MT::Template::Context->add_conditional_tag(PaginateIfMultiplePages => \&MTPaginateIfMultiplePages);
MT::Template::Context->add_conditional_tag(PaginateIfSinglePage => \&MTPaginateIfSinglePage);
--- 35,41 ----
## Register MT handlers
MT::Template::Context->add_tag(PaginateVersion => sub { $VERSION } );
! MT::Template::Context->add_container_tag(Paginate2 => \&MTPaginate );
MT::Template::Context->add_conditional_tag(PaginateIfMultiplePages => \&MTPaginateIfMultiplePages);
MT::Template::Context->add_conditional_tag(PaginateIfSinglePage => \&MTPaginateIfSinglePage);
***************
*** 78,83 ****
--- 87,103 ----
$pg->{page_selector} = $args->{page_selector} || 'page';
$pg->{mode} = $args->{mode} || 'php';
my $default_page = $args->{default_page} || 1;
+ my $paginate_url ='';
+
+ require MT::Template::Context;
+ $paginate_url = &MT::Template::Context::_hdlr_archive_link;
+ #$paginate_url = &MT::Template::Context::_hdlr_category_archive;
+
+ #elsif ($args->{urltype} eq "monthly")
+ #{
+ # require MT::Template::Context;
+ # $paginate_url = &MT::Template::Context::_hdlr_archive_link;
+ #}
## Setup context
$ctx->stash('paginate', $pg);
***************
*** 219,225 ****
$paginate_self =~ s/&$page_selector=[^&]*&/&/;
$paginate_self =~ s/^&//;
$paginate_self = '' if($paginate_self eq '&');
! $pg->{paginate_self} = "?$paginate_self$page_selector";
} elsif($pg->{mode} eq 'php') {
## Set up PHP variables: paginate_current_page ("2") and paginate_self ("/blog/page.pgp?page")
--- 239,245 ----
$paginate_self =~ s/&$page_selector=[^&]*&/&/;
$paginate_self =~ s/^&//;
$paginate_self = '' if($paginate_self eq '&');
! $pg->{paginate_self} = "/$paginate_self$page_selector";
} elsif($pg->{mode} eq 'php') {
## Set up PHP variables: paginate_current_page ("2") and paginate_self ("/blog/page.pgp?page")
***************
*** 232,241 ****
// Values that can be used in other PHP code on the page
\$paginate_num_pages = $numPages;
\$paginate_num_sections = __PAGINATE_NUM_SECTIONS__;
! \$paginate_page_selector = '$page_selector';
! \$paginate_current_page = \@\$_GET['$page_selector'];
// Pin page selector to a valid number (or 'all')
if(\$paginate_current_page=='')
\$paginate_current_page = '$default_page';
--- 252,315 ----
// Values that can be used in other PHP code on the page
+ \$paginate_page_selector = '$page_selector';
+ \$get_uri = \$_SERVER{'PATH_INFO'};
+
+ \$pathinfo_maxlength = 50;
+ \$uri_maxlength = 600;
+
+ \$my_scripts_len = strlen(\$my_scripts);
+ \$paginate_current_page = "";
+
+ \$uri_pages_pos = strpos(\$get_uri,\$paginate_page_selector);
+ if (\$uri_pages_pos !== false)
+ {
+
+ if ( substr(\$get_uri,strlen(\$paginate_page_selector) + 1,1) == "/")
+ {
+
+ if (strlen(\$get_uri) > \$pathinfo_maxlength )
+ {
+ // Path Info Too Long.
+ }
+ else
+ {
+ // Maybe Ok. //
+ \$tmp_uri = substr(\$get_uri, strlen(\$paginate_page_selector) + 2 );
+ //print "tmp: \$tmp_uri
";
+
+ if (\$tmp_uri == "all")
+ {
+ // OK //
+ \$paginate_current_page = "all";
+ }
+ else
+ {
+ \$tmp_uri2 = \$tmp_uri;
+
+ \$pattern = '/\\d+/';
+ \$replacement = '';
+ \$tmp_uri3 = preg_replace(\$pattern, \$replacement, \$tmp_uri2);
+ if (\$tmp_uri3 == "")
+ {
+ //print "Checking3...
";
+
+ #---- Maybe Ok ----
+ if ( is_numeric(\$tmp_uri2) )
+ {
+ \$paginate_current_page = \$tmp_uri2;
+ }
+ }
+ }
+ }
+ }
+ }
+
+
\$paginate_num_pages = $numPages;
\$paginate_num_sections = __PAGINATE_NUM_SECTIONS__;
!
! //\$paginate_current_page = \@\$_GET['$page_selector'];
// Pin page selector to a valid number (or 'all')
if(\$paginate_current_page=='')
\$paginate_current_page = '$default_page';
***************
*** 255,260 ****
--- 329,335 ----
\$paginate_top_section = 1;
\$paginate_bottom_section = __PAGINATE_NUM_SECTIONS__;
}
+ /*
if(isset(\$_SERVER['QUERY_STRING'])) {
\$paginate_self = '&' . \$_SERVER['QUERY_STRING'] . '&';
\$paginate_self = preg_replace("/&$page_selector=[^&]*&/", "&", \$paginate_self);
***************
*** 266,288 ****
} else {
\$paginate_self = '';
}
! PHP
- my $base_address = $args->{'base_address'} || '_relative';
- if($base_address eq '_absolute') {
- $res .=<
PHP
--- 341,389 ----
} else {
\$paginate_self = '';
}
! */
!
! //if ( strlen(\$_SERVER{'REQUEST_URI'}) >= \$uri_maxlength )
! //{
! /* It is possible to apply a /attack.
! A server resource is spent by making long String process inside.
! Although it can say that it is not great processing load, it is steadily from a small thing.
! However, restriction by HTTP GET is received in this case.
!
! For example
! http://some.url.com/archives/cat2/index.php/////////////////////////////////////////////////////////////////////////////////page/3
!
! Umm.... It is also in such cases....
! http://some.url.com/archives////////////////////////cat2/index.php/////////////////////////////////////////////////////////////////////////////////page/3
!
! http://some.url.com///////////////////////////////////////archives////////////////////////cat2/index.php/////////////////////////////////////////////////////////////////////////////////page/3
!
! */
! //It is not secure to acquire from the above-mentioned reason to URI.
! //Since the URI serves as a base when it links URL again after attaching ///purposely, it unites and is also unsavory.
!
! \$paginate_self = '$paginate_url/' . \$paginate_page_selector;
!
! //}
PHP
!
! # my $base_address = $args->{'base_address'} || '_relative';
! # if($base_address eq '_absolute') {
! # $res .=<
PHP
***************
*** 377,387 ****
my $page_selector = $pg->{page_selector};
if($pg->{mode} eq 'php') {
return < 1) echo "\$paginate_self=" . (\$paginate_current_page-1); ?>
PHP
} else {
my $current_page = $pg->{current_page};
! return ($current_page ne 'all' && $current_page > 1) ? $pg->{paginate_self} . '=' . ($current_page-1) : '';
}
}
--- 478,488 ----
my $page_selector = $pg->{page_selector};
if($pg->{mode} eq 'php') {
return < 1) echo "\$paginate_self/" . (\$paginate_current_page-1); ?>
PHP
} else {
my $current_page = $pg->{current_page};
! return ($current_page ne 'all' && $current_page > 1) ? $pg->{paginate_self} . '/' . ($current_page-1) : '';
}
}
***************
*** 391,397 ****
my $num_pages = $pg->{num_pages};
if($pg->{mode} eq 'php') {
return <
PHP
} else {
my $current_page = $pg->{current_page};
--- 492,498 ----
my $num_pages = $pg->{num_pages};
if($pg->{mode} eq 'php') {
return <
PHP
} else {
my $current_page = $pg->{current_page};
***************
*** 405,414 ****
my $num_pages = $pg->{num_pages};
if($pg->{mode} eq 'php') {
return <
PHP
} else {
! return $pg->{paginate_self} . '=all';
}
}
--- 506,522 ----
my $num_pages = $pg->{num_pages};
if($pg->{mode} eq 'php') {
return <
PHP
+
+
+ # return <
+ #PHP
} else {
! return $pg->{paginate_self} . '/all';
}
}
***************
*** 442,466 ****
PHP
$res .=<$format_all_current", $num_pages);
} else {
! echo sprintf("", $num_pages);
}
PHP
$res .=<$format_current", \$i);
} else {
! echo sprintf("", \$i);
}
}
PHP
$res .=<$format_all_current", $num_pages);
} else {
! echo sprintf("", $num_pages);
}
PHP
$res .=<$format_all_current", $num_pages);
} else {
! echo sprintf("", $num_pages);
}
PHP
$res .=<$format_current", \$i);
} else {
! echo sprintf("", \$i);
}
}
PHP
$res .=<$format_all_current", $num_pages);
} else {
! echo sprintf("", $num_pages);
}
PHP
$res .=<{current_page} eq 'all') {
$res .= "$all_current$separator";
} else {
! $res .= "{paginate_self} . "=all\"$title$target>$all$separator";
}
}
--- 588,594 ----
if($pg->{current_page} eq 'all') {
$res .= "$all_current$separator";
} else {
! $res .= "{paginate_self} . "/all\"$title$target>$all$separator";
}
}
***************
*** 492,498 ****
if($i eq $pg->{current_page}) {
$res .= sprintf("$format_current", $i);
} else {
! $res .= "{paginate_self} . "=$i\"$target" . sprintf($format_title, $i) . sprintf(">$format", $i) . '';
}
}
--- 600,606 ----
if($i eq $pg->{current_page}) {
$res .= sprintf("$format_current", $i);
} else {
! $res .= "{paginate_self} . "/$i\"$target" . sprintf($format_title, $i) . sprintf(">$format", $i) . '';
}
}
***************
*** 502,508 ****
if($pg->{current_page} eq 'all') {
$res .="$all_current$separator";
} else {
! $res .= "{paginate_self} . "=all\"$title$target>$all$separator";
}
}
} else {
--- 610,616 ----
if($pg->{current_page} eq 'all') {
$res .="$all_current$separator";
} else {
! $res .= "{paginate_self} . "/all\"$title$target>$all$separator";
}
}
} else {
***************
*** 515,525 ****
if(\$paginate_current_page == 'all') {
echo '$all_current$separator';
} else {
! echo "$all$separator";
}
PHP
}
$format_title = " . sprintf(' title=\"$format_title\"', \$i)" if $format_title;
$res .=<$all$separator";
}
PHP
}
+
$format_title = " . sprintf(' title=\"$format_title\"', \$i)" if $format_title;
$res .=<$format', \$i) . '';
}
}
PHP
--- 637,643 ----
if(\$i == \$paginate_current_page) {
echo sprintf("$format_current", \$i);
} else {
! echo "$format', \$i) . '';
}
}
PHP
***************
*** 539,545 ****
if(\$paginate_current_page == 'all') {
echo '$separator$all_current';
} else {
! echo "$separator$all";
}
PHP
}
--- 648,654 ----
if(\$paginate_current_page == 'all') {
echo '$separator$all_current';
} else {
! echo "$separator$all";
}
PHP
}