작은숲:위키노트/모니위키 패치/1.1.0-20050104
적용한 MoniWiki Release: 1.1.0-20050104
Good writeup, I am normal visitor of ones blog, maintain up the excellent operate, and It's going to be a regular visitor for a lengthy time. kebcfgafkfcfgedk
페이지에서 TwinPages가 나오지 않도록 설정 가능
TwinPages가 나오도록 설정된 경우라도 페이지 상단에 #notwins를 넣으면 그 페이지에서는 TwinPages가 나오지 않는다.
--- wiki.dist.php 2005-01-20 00:16:25.000000000 +0900
+++ wiki.php 2005-01-20 15:43:21.000000000 +0900
@@ -1469,7 +1469,7 @@
function get_instructions(&$body) {
global $DBInfo;
- $pikeys=array('#redirect','#action','#title','#keywords','#noindex');
+ $pikeys=array('#redirect','#action','#title','#keywords','#noindex','#notwins');
$pi=array();
if (!$body) {
if (!$this->page->exists()) return '';
@@ -2138,7 +2138,8 @@
return;
}
- $twins=$DBInfo->metadb->getTwinPages($this->page->name,$DBInfo->use_twinpages);
+ if (empty($pi['#notwins']))
+ $twins=$DBInfo->metadb->getTwinPages($this->page->name,$DBInfo->use_twinpages);
if ($body) {
$body=rtrim($body); # delete last empty line
$lines=explode("n",$body);
SisterWiki Index 나오는 형태 수정
SisterWiki Index 나오는 줄 위에 나오는 ----를 <hr>로 바꾼다.
--- wiki.dist.php 2005-01-20 00:16:25.000000000 +0900
+++ wiki.php 2005-01-20 15:43:21.000000000 +0900
@@ -2453,7 +2457,7 @@
if ($this->sisters and !$options['nosisters']) {
$sisters=join("n",$this->sisters);
$sisters=preg_replace("/(".$wordrule.")/e","$this->link_repl('1')",$sisters);
- print "<div id='wikiSister'>n<tt class='foot'>----</tt><br/>nSister Sites Index<br />n$sisters</div>n";
+ print "<div id='wikiSister'>n<hr class='wiki' />nSister Sites Index<br />n$sisters</div>n";
}
if ($options['pagelinks']) $this->store_pagelinks();
$external_target 제대로 동작시키기
config.php에 $external_target을 설정해둔 경우 외부 링크인 경우 target이 $external_target으로 설정된 값으로 적용되어야 하는데, 제대로 되지 않는다. 이를 제대로 동작시키기 위해 wiki.php를 수정한다.
--- wiki.dist.php 2005-01-20 00:16:25.000000000 +0900
+++ wiki.php 2005-01-20 16:06:54.000000000 +0900
@@ -1335,7 +1335,7 @@
if ($DBInfo->external_on == 0) $this->external_on = 0;
$this->external_target='';
if ($DBInfo->external_target)
- $this->external_target='target="'.$DBInfo->external_target.'" ';
+ $this->external_target='target="'.$DBInfo->external_target.'"';
#$this->baserule=array("/<([^s][^>]*)>/","/`([^`]*)`/",
$this->baserule=array("/<([^s<>])/","/`([^`' ]+)'/","/(?<!`)`([^`]*)`/",
@@ -1655,7 +1655,7 @@
return "<img alt='$link' $attr src='$url' />";
}
}
- return "<a class='externalLink' $attr href='$link' $this->ex_target>$url</a>";
+ return "<a class='externalLink' $attr href='$link' $this->external_target>$url</a>";
} else {
if ($url[0]=="?") $url=substr($url,1);
return $this->word_repl($url,'',$attr);
@@ -1716,7 +1716,7 @@
if (preg_match("/.(png|gif|jpeg|jpg)$/i",$url))
return "<a href='".$url."' $attr title='$wiki:$page'>".
"<img border='0' align='middle' alt='$text' src='$url' /></a>$extra";
- return $img. "<a href='".$url."' $attr title='$wiki:$page'>$text</a>$extra";
+ return $img. "<a href='".$url."' $attr $this->external_target title='$wiki:$page'>$text</a>$extra";
}
function store_pagelinks() {
Navigation Macro를 사용할 때, 인덱스 파일에 아래와 같이 썼을 때
* [wiki:/Something 새로운 것들]
제대로 인식하지 못하는 문제가 발생한다. 이 문제를 수정해주기 위해 wikilib.php 파일의 normalize_word() 함수를 수정한다.
--- wikilib.dist.php 2005-01-04 18:41:21.000000000 +0900
+++ wikilib.php 2005-01-21 14:43:02.000000000 +0900
@@ -134,6 +134,19 @@
}
}
+ if (preg_match("/^wiki:/", $page)) { # wiki:
+ $dum = explode(":", $page, 2);
+ $page = $text = $dum[1];
++ if (strpos($page, " ")) { # have a space ?
+ $dum = explode(" ", $page, 2);
+ $page = $dum[0];
+ $text = $dum[1];
+ }
++ if ($page[0] == '/') $page = $pagename . $page;
+ }
+ return array($page,$text,$main_page);
}
Navigation Macro를 사용할 때, 인덱스 파일에 아래와 같이 적었을 때
* [wiki:Something 새로운 것들]
Navigation 목록에 "새로운 것들"이라는 제목이 아닌 파일 이름 "Something"가 나오게 된다. 이것을 "새로운 것들"이라는 제목이 나오도록 수정한다.
--- Navigation.dist.php 2004-11-03 03:01:55.000000000 +0900
+++ Navigation.php 2005-01-21 14:54:43.000000000 +0900
@@ -35,6 +35,7 @@
# print $current;
$indices=array();
+ $texts = array();
$count=0;
foreach ($lines as $line) {
if (preg_match("/^s+(*|d+.)s+(?<!!)($formatter->wordrule)/",$line,$match)) {
@@ -43,9 +44,9 @@
if ($word[0]=='"') $word=substr($word,1,-1);
list($index,$text,$dummy)= normalize_word($word,$group,$page);
- if ($group)
- $indices[]=$index;
+ if ($group) $indices[]=$index;
else $indices[]=$index;
+ $texts[] = $text;
$count++;
}
}
@@ -66,11 +67,16 @@
#print $indices[$i];
#print ':'.$formatter->page->name;
if ($indices[$i]==$current) {
- if ($i > 0) $prev=$indices[$i-1];
+ if ($i > 0) {
+ $prev=$indices[$i-1];
+ $prev_text = $texts[$i - 1];
+ }
if ($i < ($count - 1)) {
- $next=$indices[$i+1];
+ $next=$indices[$i+1];
+ $next_text = $texts[$i + 1];
} else {
$next = '';
+ $next_text = '';
}
}
}
@@ -83,7 +89,7 @@
}
$pnut='« ';
if ($prev) {
- $prev_text=$prev;
+ //$prev_text=$prev;
if (($p=strpos($prev,'~'))!==false)
$prev_text=substr($prev,$p+1);
$pnut.=$formatter->link_repl("[wiki:$prev $prev_text]"," accesskey="," ");
@@ -92,7 +98,7 @@
$pnut.=" | ".$formatter->link_repl("[wiki:$index $index_text]")." | ";
if ($use_action) $formatter->query_string=$query;
if ($next) {
- $next_text=$next;
+ //$next_text=$next;
if (($p=strpos($next,'~'))!==false)
$next_text=substr($next,$p+1);
$pnut.=$formatter->link_repl("[wiki:$next $next_text]"," accesskey="." ");
UploadFile 매크로를 이용해 파일을 첨부했을 때 로그 남기지 않게 하기
--- UploadFile.dist.php 2004-12-21 06:08:33.000000000 +0900
+++ UploadFile.php 2005-01-20 00:54:32.000000000 +0900
@@ -175,7 +175,7 @@
$p->write($raw_body);
$DBInfo->savePage($p,$comment,$options);
} else
- $DBInfo->addLogEntry($key, $REMOTE_ADDR,$comment,"UPLOAD");
+ //$DBInfo->addLogEntry($key, $REMOTE_ADDR,$comment,"UPLOAD");
$formatter->send_header("",$options);
if ($uploaded < 2) {
Icon Macro 수정
테마를 사용하는 경우 theme/my_theme/theme.php에서 아이콘을 설정하는 경우가 있다. 대표적인 것이 고미다님의 coldgray 테마인데, 이런 경우 Icon 매크로를 사용할 경우 config.php에서 설정된 아이콘셋의 아이콘이 나오게 된다. 이것을 $Formatter에 설정된 아이콘이 나올 수 있도록 설정한다.
--- Icon.dist.php 2005-01-24 16:24:08.000000000 +0900
+++ Icon.php 2005-01-24 16:25:14.000000000 +0900
@@ -13,6 +13,10 @@
$realdir=basename($DBInfo->imgs_dir);
$img=strtok('');
if (is_dir($realdir.'/'.$dir)) $value=$dir.'/'.$img;
+ } else if (isset($formatter->icon[$value])) {
+ return $formatter->icon[$value];
+ } else if ($value == 'deleted') {
+ return $formatter->icon[del];
} else if (! preg_match('/\.(gif|png|jpg|jpeg)$/',$value)) {
$value=$DBInfo->iconset.'/'.$value.'.png';
}
blog processor 수정
블러그에서 로그인하지 않은 상태에서 글을 남기게 되면, 글쓴이 이름에 IP 주소가 나오게 되어 있다. 이 부분을 IP 주소가 보이지 않도록 하고, 링크를 통해서 Whois 할 수 있도록 plugin/processor/blog.php를 수정한다.
--- blog.php 2005/01/31 23:54:05 1.1
+++ blog.php 2005/01/31 23:55:56
@@ -40,7 +40,7 @@
if (preg_match('/^[\d\.]+$/',$user)) {
if ($DBInfo->interwiki['Whois'])
- $user=_("Anonymous")."[<a href='".$DBInfo->interwiki['Whois']."$user'>$user</a>]";
+ $user="<a href='".$DBInfo->interwiki['Whois']."$user'>". _("Anonymous") ."</a>";
else
$user=_("Anonymous");
} else if ($DBInfo->hasPage($user)) {
Blog에서 댓글을 달 때 필명 처리 수정
Blog 액션을 통해 댓글을 달면 필명이 글쓴이에 상관없이 "-- 필명 날짜" 이런 식으로 나오게 된다. 이를 좀더 세분화해서 로그인한 사용자인 경우, 그리고 자신의 위키홈페이지가 있는 경우 등을 따져 다르게 표현되도록 plugin/Blog.php를 수정한다. 그리고, 덤으로 댓글 입력의 경우 글 마지막의 개행문자나 공백 문자를 trim() 함수를 통해 삭제한다.
--- Blog.php 2005/01/31 23:47:38 1.1
+++ Blog.php 2005/01/31 23:56:12
@@ -91,6 +91,7 @@
$savetext=stripslashes($options['savetext']);
$savetext=str_replace("\r","",$savetext);
$savetext=str_replace("----\n","-''''''---\n",$savetext);
+ $savetext = trim($savetext);
#$savetext=str_replace("<","<",$savetext);
}
@@ -147,8 +148,15 @@
}
if ($options['nosig'])
$lines[$i]="----\n$savetext\n$endtag";
+ else if ($id != 'Anonymous')
+ {
+ if ($DBInfo->hasPage($id))
+ $lines[$i]="----\n$savetext --[$id] [[Date(2005-02-01T00:03:07)]]\n$endtag";
+ else
+ $lines[$i]="----\n$savetext --$id [[Date(2005-02-01T00:03:07)]]\n$endtag";
+ }
else
- $lines[$i]="----\n$savetext -- $id [[Date(2005-02-01T00:03:07)]]\n$endtag";
+ $lines[$i]="----\n$savetext --$id [[Date(2005-02-01T00:03:07)]]\n$endtag";
$raw_body=join("\n",$lines);
} else {
$formatter->send_title(_("Error: No blog entry found!"),"",$options);
needtologin security class 수정
지금 사용하고 있는 Security class인 needthlogin 중에 로그인하지 않아도 블러그를 작성할 수 있도록 plugin/security/needtologin.php 파일을 수정하고 plugin/security/mysecurity.php로 복사한 후, config.php에서 security class를 $security_class = 'mysecurity';와 같이 설정해준다.
--- needtologin.php 2005/02/01 00:11:36 1.1
+++ needtologin.php 2005/02/01 00:11:55
@@ -29,7 +29,9 @@
}
function may_blog($action,&$options) {
+ $public_pages=array('WikiSandBox','WikiSandbox','GuestBook','SandBox');
if (!$options['page']) return 0; # XXX
+ if (in_array($options['page'],$public_pages)) return 1;
if ($options['id']=='Anonymous') {
$options['err']=sprintf(_("You are not allowed to '%s' on this page"),$action);
$options['err'].="\n"._("Please Login or make your ID on this Wiki ;)");
attachment 매크로를 사용할 때 그림 파일 저장하지 못하게 하기
attachment로 페이지에 올리는 그림 파일의 경우에는 일반 사용자들이 로컬 컴퓨터에 저장하지 못하도록 마우스 오른쪽 버튼을 누를 때 나오는 메뉴와 드래그를 못하도록 한다.
물론 이것은 현명한 방법은 아니다. 그리고, 그림 파일을 저장하지 못하게 하는 근본적인 방법은 없을 것이다. 다만, 이렇게라도 해서 그림 파일 혹은 사진이 아무렇게나 돌아다니는 것을 조금이나마 막을 수 있을 것이다.
이를 위해 config.php에서 설정할 수 있는 $owners를 이용한다. 원래 $owners는 개인 위키에서 주인장이 페이지를 보더라도 페이지 카운트가 되지 않도록 하기 위해 사용되지만, 이를 이용해서 $owners가 설정된 경우에는 주인장으로 간주하고 위에서 말한 방지책이 실행되지 않도록 한다.
--- Attachment.php 2005/02/28 17:58:54 1.1
+++ Attachment.php 2005/02/28 17:59:30
@@ -71,7 +71,11 @@
$url=$formatter->link_url(_urlencode($pagename),"?action=$mydownload&value=$value");
else
$url=$DBInfo->url_prefix."/"._urlencode($upload_file);
- return "<span class=\"imgAttach\"><img src='$url' alt='$file' $attr/></span>";
+ $alt = preg_replace("/\.(png|gif|jpeg|jpg)$/i", "", $file);
+ $user = new User();
+ if ($DBInfo->owners and !in_array($user->id, $DBInfo->owners))
+ $attr .= " oncontextmenu='return false;' ondragstart='return false;' ";
+ return "<span class=\"imgAttach\"><img src='$url' alt='$alt' $attr/></span>";
} else {
테이블 첫번째 셀에서 rowspan을 쓸 때의 오류 수정
||을 이용해서 테이블을 사용할 경우, 첫번째 줄의 첫번째 셀에서 <|10>와 같이 rowspan을 사용할 경우 제대로 동작하지 않는 문제점을 수정한다.
--- wiki.php 2005/02/01 01:25:35 1.3
+++ wiki.php 2005/03/01 12:02:40
@@ -2342,9 +2342,9 @@
}
#if (!$in_pre && !$in_table && preg_match("/^\|\|.*\|\|$/",$line)) {
- if (!$in_pre && $line[0]=='|' && !$in_table && preg_match("/^((\|\|)+)(<[^>]+>)?.*\|\|$/",$line,$match)) {
+ if (!$in_pre && $line[0]=='|' && !$in_table && preg_match("/^((\|\|)+)(<[^\|>]+>)?.*\|\|$/",$line,$match)) {
$open.=$this->_table(1,$match[3]);
- $line=preg_replace('/^((\|\|)+)(<[^>]+>)?/','\\1',$line);
+ $line=preg_replace('/^((\|\|)+)(<[^\|>]+>)?/','\\1',$line);
$in_table=1;
#} elseif ($in_table && !preg_match("/^\|\|.*\|\|$/",$line)){
} elseif ($in_table && $line[0]!='|' && !preg_match("/^\|\|.*\|\|$/",$line)){
Multi Line Cell 렌더링 수정
들여쓰기 상태인 단락에서 {{| ... |}}을 이용하면 들여쓰기가 제대로 되지 않는다.
--- wiki.php 2005/03/01 12:02:39 1.5
+++ wiki.php 2005/03/23 05:33:39
@@ -1360,8 +1361,9 @@
# NoSmoke's MultiLineCell hack
$this->extrarule=array("/{{\|/","/\|}}/");
- $this->extrarepl=array("</div><table class='closure'><tr class='closure'><td class='closure'><div>",
- "</div></td></tr></table><div>");
+ $this->extrarepl=array("<table class='closure'><tr class='closure'><td class='closure'><div>",
+ "</div></td></tr></table>");
# set smily_rule,_repl
if ($DBInfo->smileys) {
$smiley_rule='/(?<=\s|^)('.$DBInfo->smiley_rule.')(?=\s|$)/e';
각 페이지별로 Security Class를 지정
페이지 상단에 #security PI를 써서 페이지별로 Security Class를 따로 지정하게 한다.
--- wiki.php 2005/03/01 12:02:39 1.5
+++ wiki.php 2005/03/23 05:33:39
@@ -1470,7 +1472,7 @@
function get_instructions(&$body) {
global $DBInfo;
- $pikeys=array('#redirect','#action','#title','#keywords','#noindex','#notwins','#nocomment','#protected');
+ $pikeys=array('#redirect','#action','#title','#keywords','#noindex','#notwins','#nocomment','#security');
$pi=array();
if (!$body) {
if (!$this->page->exists()) return '';
@@ -3265,6 +3271,15 @@
}
}
+ $pi = $formatter->get_instructions($raw_dummy);
+ if (isset($pi['#security']) and file_exists("plugin/security/". $pi['#security'] .".php"))
+ {
+ include_once("plugin/security/". $pi['#security'] .".php");
+ $class = "Security_". $pi['#security'];
+ $DBInfo->security = new $class ($DBInfo);
+ }
+ $formatter->pi = $pi;
+ if (!$action or $action=='show') {
if ($value) { # ?value=Hello
$options['value']=$value;
@@ -3331,7 +3346,19 @@
# }
#$formatter->get_redirect();
- $formatter->pi=$formatter->get_instructions($dum);
+ $formatter->pi = $formatter->get_instructions($dum);
++ if (!$DBInfo->security->readable($options))
+ {
+ $msg = sprintf(_("You are not allowed to '%s'"), "show");
+ $formatter->send_header("Status: 406 Not Acceptable", $options);
+ $formatter->send_title($msg, "", $options);
+ if ($options['err'])
+ $formatter->send_page($options['err']);
+ $formatter->send_footer($args, $options);
+ return;
+ }
+ if ($DBInfo->body_attr)
$options['attr']=$DBInfo->body_attr;
$formatter->send_header("",$options);
HTTP Request에서 한글 페이지의 인코딩 문제 해결
브라우저 설정에 따라 한글 코드가 euc-kr 혹은 utf-8로 HTTP Request가 오게 된다. MoniWiki의 기본 인코딩이 utf-8로 설정된 경우 euc-kr로 인코딩된 요청이 오면 제대로 보여줄 수 없는데, 이를 해결하기 위해 아래 내용을 추가한다.
--- wiki.php 2005/03/01 12:02:39 1.5
+++ wiki.php 2005/03/23 05:33:39
@@ -3205,6 +3207,10 @@
}
$pagename=get_pagename();
+$orgname = $pagename;
+if (strtolower($DBInfo->charset) == 'utf-8' and iconv("utf-8", "utf-8", $pagename) != $pagename)
+ $pagename = iconv("euc-kr", "utf-8", $pagename);
+ //function render($pagename,$options) {
if ($pagename) {
global $DBInfo;
ISBN 매크로에서 "k"로 파라미터를 줬을 때 제대로 인식시키기
ISBN 매크로에서 "k"로 주면 제대로 알라딘으로 연결되지 않는다. "K"로 주어야만 제대로 되는데, 이를 해결하기 위한 패치. 이미지 태그 속성을 지원하는 과정에서 발생된 문제인 것 같다.
--- ISBN.php 2005/01/24 07:44:01 1.1
+++ ISBN.php 2005/03/28 01:06:39
@@ -13,7 +13,7 @@
EOS;
$DEFAULT_ISBN="Amazon";
- $re_isbn="/([0-9\-]{9,}[xX]?)(?:\s*,\s*)?([A-Z][A-Za-z]*)?(?:\s*,\s*)?(.*)?/";
+ $re_isbn="/([0-9\-]{9,}[xX]?)(?:\s*,\s*)?([kA-Z][A-Za-z]*)?(?:\s*,\s*)?(.*)?/";
$test=preg_match($re_isbn,$value,$match);
if ($test === false)
@@ -32,6 +32,7 @@
$args=explode(",",$match[3]);
foreach ($args as $arg) {
if ($arg == "noimg") $noimg=1;
+ //else if ($arg == "k") $lang = "Aladdin";
else {
$name=strtok($arg,'=');
$val=strtok(' ');
@@ -87,7 +88,7 @@
return $formatter->icon['www']."[<a href='$booklink'>ISBN-$isbn2</a>]";
else
return "<a href='$booklink'><img src='$imglink' border='1' title='$lang".
- ":ISBN-$isbn' alt='[ISBN-$isbn2]' $attr /></a>";
+ ":ISBN-$isbn' alt='[ISBN-$isbn2]' class='isbn' $attr /></a>";
}
?>
들여쓰기 렌더링 수정
config.php에서 $auto_linebreak를 설정하지 않은 경우, 들여쓰기 중일 때 한줄 띄어도 빈줄이 들어오지 않는다. 이를 수정하기 위해 wiki.php의 send_page() 함수를 수정한다.
--- wiki.php 2005/03/23 05:33:38 1.7
+++ wiki.php 2005/03/30 08:10:41
@@ -2415,6 +2415,8 @@
}
if ($DBInfo->auto_linebreak && !$in_table && !$this->nobr)
$text.=$line."<br />\n";
+ else if (!$DBInfo->auto_linebreak and $in_li)
+ $text .= $line ."<br />\n";
else
$text.=$line."\n";
$this->nobr=0;
글 색깔 지정 문법 오류 수정
{{{#color ...}}} 문법을 사용해서 글 색깔을 지정할 때 블럭 안의 첫 단어까지만 잘려서 나오는 오류를 수정한다.
--- wiki.php 2005/03/30 08:10:40 1.8
+++ wiki.php 2005/04/06 08:34:19
@@ -1573,7 +1573,7 @@
case '{':
$url=substr($url,3,-3);
if ($url[0]=='#' and ($p=strpos($url,' '))) {
- $col=strtok($url,' '); $url=strtok(' ');
+ list($col, $url) = split(" ", $url, 2);
if (!preg_match('/^#[0-9a-f]{6}$/',$col)) $col=substr($col,1);
return "<font color='$col'>$url</font>";
}