OSDN Git Service

setup.datでページの最大サイズと差分表示の最大サイズを指定できるようにした。
authortakezoe <takezoe@users.osdn.me>
Sat, 13 Aug 2011 19:05:05 +0000 (19:05 +0000)
committertakezoe <takezoe@users.osdn.me>
Sat, 13 Aug 2011 19:05:05 +0000 (19:05 +0000)
plugin/core/Diff.pm
plugin/core/EditPage.pm
setup.dat

index b8c1e5d..960acde 100644 (file)
@@ -34,9 +34,11 @@ sub do_action {
        }
        if($cgi->param('rollback') ne ''){
                return $self->rollback($wiki, $pagename, $cgi->param('rollback'));
+               
        } elsif($wiki->{storage}->backup_type eq 'all'){
                if($cgi->param('generation') eq '' && $cgi->param('diff') eq ''){
                        return $self->show_history($wiki, $pagename);
+                       
                } else {
                        if($cgi->param('generation') ne ''){
                                return $self->show_diff($wiki, $pagename, '', $cgi->param('generation'));
@@ -215,12 +217,24 @@ sub get_diff_html {
        } else {
                $source1 = $wiki->get_page($page);
        }
+       if($wiki->config('diff_max') ne '' && $wiki->config('diff_max') > 0){
+               if(length($source1) > $wiki->config('diff_max')){
+                       return ('¥Ú¡¼¥¸¥µ¥¤¥º¤¬Â礭¤¤¤¿¤áº¹Ê¬¤òɽ¼¨¤Ç¤­¤Þ¤»¤ó¡£', 0);
+               }
+       }
+       
        my $source2 = '';
        if($to ne ''){
                $source2 = $wiki->get_backup($page, $to);
        } else {
                $source2 = $wiki->get_page($page);
        }
+       if($wiki->config('diff_max') ne '' && $wiki->config('diff_max') > 0){
+               if(length($source2) > $wiki->config('diff_max')){
+                       return ('¥Ú¡¼¥¸¥µ¥¤¥º¤¬Â礭¤¤¤¿¤áº¹Ê¬¤òɽ¼¨¤Ç¤­¤Þ¤»¤ó¡£', 0);
+               }
+       }
+       
        my $format  = $wiki->get_edit_format();
        
        $source1 = $wiki->convert_from_fswiki($source1, $format);
index 250117b..e33d217 100644 (file)
@@ -47,7 +47,12 @@ sub do_action {
        #--------------------------------------------------------------------------
        # Êݸ½èÍý
        if($cgi->param("save") ne ""){
-               if($wiki->page_exists($pagename) && $cgi->param("lastmodified") != $time){
+               if($wiki->config('page_max') ne '' && $wiki->config('page_max') > 0){
+                       if(length($content) > $wiki->config('page_max')){
+                               return $wiki->error('¥Ú¡¼¥¸¤¬Êݸ²Äǽ¤ÊºÇÂ祵¥¤¥º¤òĶ¤¨¤Æ¤¤¤Þ¤¹¡£');
+                       }
+               }
+               if($wiki->page_exists($pagename) && $cgi->param("lastmodified") != $time){
                        $buf .= "<p><span class=\"error\">¥Ú¡¼¥¸¤Ï´û¤ËÊ̤Υ桼¥¶¤Ë¤è¤Ã¤Æ¹¹¿·¤µ¤ì¤Æ¤¤¤Þ¤¹¡£</span></p>";
                        
                        my $mode = $wiki->get_edit_format();
@@ -105,6 +110,11 @@ sub do_action {
        #--------------------------------------------------------------------------
        # ¥×¥ì¥Ó¥å¡¼½èÍý
        } elsif($cgi->param("preview") ne ""){
+               if($wiki->config('page_max') ne '' && $wiki->config('page_max') > 0){
+                       if(length($content) > $wiki->config('page_max')){
+                               return $wiki->error('¥Ú¡¼¥¸¤¬Êݸ²Äǽ¤ÊºÇÂ祵¥¤¥º¤òĶ¤¨¤Æ¤¤¤Þ¤¹¡£');
+                       }
+               }
                $time = $cgi->param("lastmodified");
                $buf = "°Ê²¼¤Î¥×¥ì¥Ó¥å¡¼¤ò³Îǧ¤·¤Æ¤è¤í¤·¤±¤ì¤Ð¡ÖÊݸ¡×¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£<br>";
                if($content eq ""){
index 39a16d2..4f79ea1 100644 (file)
--- a/setup.dat
+++ b/setup.dat
@@ -91,6 +91,12 @@ frontpage = FrontPage
 # POST¥á¥½¥Ã¥É¤ÎºÇÂ祵¥¤¥º¡Ê-1¤À¤È̵À©¸Â¡Ë
 post_max = -1
 
+# ¥Ú¡¼¥¸¤ÎºÇÂ祵¥¤¥º¡Ê0°Ê²¼¤â¤·¤¯¤Ï¾Êά¤¹¤ë¤È̵À©¸Â¡Ë
+page_max = 1048576
+
+# º¹Ê¬É½¼¨¤ÎºÇÂ祵¥¤¥º¡Ê0°Ê²¼¤â¤·¤¯¤Ï¾Êά¤¹¤ë¤È̵À©¸Â¡Ë
+diff_max = 1048576
+
 #=====================================================================
 # ¥×¥í¥­¥·¥µ¡¼¥Ð¤ò»ÈÍѤ¹¤ë¾ì¹ç
 #=====================================================================