[[FrontPage]]

***Pukiwiki カスタマイズ履歴 [#ya700d72]

#contents

***amazon.inc.php の改変 [#ua849e8c]
 52,54d51
 < // Amazon AWS ID
 < define('AWS_ACCESS_KEY_ID', '<ここに Amazon Web Service ID を記入>');
 < 
 73,76c70,71
 <      //define('PLUGIN_AMAZON_XML', 'http://xml.amazon.co.jp/onca/xml3?t=webservices-20&' .
 <      //'dev-t=GTYDRES564THU&type=lite&page=1&f=xml&locale=jp&AsinSearch=');
 <      define('PLUGIN_AMAZON_XML', 'http://ecs.amazonaws.jp/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=' .
 <      AWS_ACCESS_KEY_ID . '&Operation=ItemLookup&Version=2007-10-29&ItemId=');
 ---
 >      define('PLUGIN_AMAZON_XML', 'http://xml.amazon.co.jp/onca/xml3?t=webservices-20&' .
 >              'dev-t=GTYDRES564THU&type=lite&page=1&f=xml&locale=jp&AsinSearch=');
 301c296
 <              preg_match('/<Title>([^<]*)</', $body, $tmpary);
 ---
 >              preg_match('/<ProductName>([^<]*)</', $body, $tmpary);



***ロゴ画像 [#r44a4768]

ロゴ画像は Zapfino + OmniGraffle Pro を使って描画しています.そのうち XeTeX で
書き直します.MyTeXpert という文字列を My, TeX, pert の三つに分割して,それぞれ
色をつけています.

***mimetex [#q968ea39]

mimetex を cgi-bin/mimetex.cgi に設置してありますので,$ だけで TeX 数式が使えます.

***default.ini.php [#y993179b]
 $attach_link = 0;
 $related_link = 0;
 $usefacemark = 0;

$line_rules に mimetex  用のルールを追加してあります.
      '\$\$([^\$]+?)\$\$'=> '<center><img src="/cgi-bin/mimetex.cgi?\\1"\ /></center>',
      '\$([^\$]+?)\$'    => '<img src="/cgi-bin/mimetex.cgi?\\1"\ />',    

これにより,簡単にTex文法数式(例:$f(x)={\Large\frac1{\sigma\sqrt{2\pi}}} \int_{\small-\infty}^xe^{-\small\frac{(t-\mu)^2}{2\sigma^2}}dt$)が出力できます.

ディスプレイ数式の例:
$$\large         f(x)={\Large\frac1{\sigma\sqrt{2\pi}}} \int_{\small-\infty}^xe^{-\small\frac{(t-\mu)^2}{2\sigma^2}}dt$$

***pukiwiki.ini.php [#h2f0c1ed]

 $page_title = 'MyTeXpert';
 $modifier = 'thortex';
 $modifierlink = 'http://mytexpert.osdn.jp/';
 
 $edit_auth = 1
 '#.#' => 'user',
として全てのページの書き換えにパスワードが必要になるように変更.

***skin/pukiwiki.sin.php [#f8b0a7ba]
 *** orig/skin/pukiwiki.skin.php	2006-03-07 23:03:02.000000000 +0900
 --- skin/pukiwiki.skin.php	2007-07-01 18:00:29.000000000 +0900
 ***************
 *** 12,25 ****
   // Settings (define before here, if you want)
   
   // Set site identities
 ! $_IMAGE['skin']['logo']     = 'pukiwiki.png';
   $_IMAGE['skin']['favicon']  = ''; // Sample: 'image/favicon.ico';
   
   // SKIN_DEFAULT_DISABLE_TOPICPATH
   //   1 = Show reload URL
   //   0 = Show topicpath
   if (! defined('SKIN_DEFAULT_DISABLE_TOPICPATH'))
 ! 	define('SKIN_DEFAULT_DISABLE_TOPICPATH', 1); // 1, 0
   
   // Show / Hide navigation bar UI at your choice
   // NOTE: This is not stop their functionalities!
 --- 12,25 ----
   // Settings (define before here, if you want)
   
   // Set site identities
 ! $_IMAGE['skin']['logo']     = 'mytexpert.png';
   $_IMAGE['skin']['favicon']  = ''; // Sample: 'image/favicon.ico';
   
   // SKIN_DEFAULT_DISABLE_TOPICPATH
   //   1 = Show reload URL
   //   0 = Show topicpath
   if (! defined('SKIN_DEFAULT_DISABLE_TOPICPATH'))
 ! 	define('SKIN_DEFAULT_DISABLE_TOPICPATH', 0); // 1, 0
   
   // Show / Hide navigation bar UI at your choice
   // NOTE: This is not stop their functionalities!
 ***************
 *** 29,35 ****
   // Show / Hide toolbar UI at your choice
   // NOTE: This is not stop their functionalities!
   if (! defined('PKWK_SKIN_SHOW_TOOLBAR'))
 ! 	define('PKWK_SKIN_SHOW_TOOLBAR', 1); // 1, 0
   
   // ------------------------------------------------------------
   // Code start
 --- 29,35 ----
   // Show / Hide toolbar UI at your choice
   // NOTE: This is not stop their functionalities!
   if (! defined('PKWK_SKIN_SHOW_TOOLBAR'))
 ! 	define('PKWK_SKIN_SHOW_TOOLBAR', 0); // 1, 0
   
   // ------------------------------------------------------------
   // Code start
 ***************
 *** 87,93 ****
   <body>
   
   <div id="header">
 !  <a href="<?php echo $link['top'] ?>"><img id="logo" src="<?php echo IMAGE_DIR . $image['logo'] ?>" width="80" height="80" alt="[PukiWiki]" title="[PukiWiki]" /></a>
   
    <h1 class="title"><?php echo $page ?></h1>
   
 --- 87,93 ----
   <body>
   
   <div id="header">
 !  <a href="<?php echo $link['top'] ?>"><img id="logo" src="<?php echo IMAGE_DIR . $image['logo'] ?>" width="149" height="96" alt="[PukiWiki]" title="[PukiWiki]" /></a>
   
    <h1 class="title"><?php echo $page ?></h1>
   
 ***************
 *** 100,108 ****
      </span>
    <?php } ?>
   <?php } ?>
 - 
   </div>
   
   <div id="navigator">
   <?php if(PKWK_SKIN_SHOW_NAVBAR) { ?>
   <?php
 --- 100,111 ----
      </span>
    <?php } ?>
   <?php } ?>
   </div>
   
 + <?php if ($lastmodified != '') { ?>
 + <div id="lastmodified">最終更新:<?php echo $lastmodified ?></div>
 + <?php } ?>
 + 
   <div id="navigator">
   <?php if(PKWK_SKIN_SHOW_NAVBAR) { ?>
   <?php
 ***************
 *** 120,126 ****
   	return TRUE;
   }
   ?>
 !  [ <?php _navigator('top') ?> ] &nbsp;
   
   <?php if ($is_page) { ?>
    [
 --- 123,170 ----
   	return TRUE;
   }
   ?>
 ! 
 ! <?php
 ! 
 ! // Set toolbar-specific images
 ! $_IMAGE['skin']['reload']   = 'reload.png';
 ! $_IMAGE['skin']['new']      = 'new.png';
 ! $_IMAGE['skin']['edit']     = 'edit.png';
 ! $_IMAGE['skin']['freeze']   = 'freeze.png';
 ! $_IMAGE['skin']['unfreeze'] = 'unfreeze.png';
 ! $_IMAGE['skin']['diff']     = 'diff.png';
 ! $_IMAGE['skin']['upload']   = 'file.png';
 ! $_IMAGE['skin']['copy']     = 'copy.png';
 ! $_IMAGE['skin']['rename']   = 'rename.png';
 ! $_IMAGE['skin']['top']      = 'top.png';
 ! $_IMAGE['skin']['list']     = 'list.png';
 ! $_IMAGE['skin']['search']   = 'search.png';
 ! $_IMAGE['skin']['recent']   = 'recentchanges.png';
 ! $_IMAGE['skin']['backup']   = 'backup.png';
 ! $_IMAGE['skin']['help']     = 'help.png';
 ! $_IMAGE['skin']['rss']      = 'rss.png';
 ! $_IMAGE['skin']['rss10']    = & $_IMAGE['skin']['rss'];
 ! $_IMAGE['skin']['rss20']    = 'rss20.png';
 ! $_IMAGE['skin']['rdf']      = 'rdf.png';
 ! 
 ! function _toolbar($key, $x = 20, $y = 20){
 ! 	$lang  = & $GLOBALS['_LANG']['skin'];
 ! 	$link  = & $GLOBALS['_LINK'];
 ! 	$image = & $GLOBALS['_IMAGE']['skin'];
 ! 	if (! isset($lang[$key]) ) { echo 'LANG NOT FOUND';  return FALSE; }
 ! 	if (! isset($link[$key]) ) { echo 'LINK NOT FOUND';  return FALSE; }
 ! 	if (! isset($image[$key])) { echo 'IMAGE NOT FOUND'; return FALSE; }
 ! 
 ! 	echo '<a href="' . $link[$key] . '">' .
 ! 		'<img src="' . IMAGE_DIR . $image[$key] . '" width="' . $x . '" height="' . $y . '" ' .
 ! 			'alt="' . $lang[$key] . '" title="' . $lang[$key] . '" />' .
 ! 		'</a>';
 ! 	return TRUE;
 ! }
 ! 
 ! ?>
 ! 
 ! [<?php _navigator('top') ?>]
   
   <?php if ($is_page) { ?>
    [
 ***************
 *** 138,143 ****
 --- 182,189 ----
   	| <?php _navigator('upload') ?>
    <?php } ?>
    | <?php _navigator('reload') ?>
 +  | <?php _navigator('copy') ?>
 +  | <?php _navigator('rename') ?>
    ] &nbsp;
   <?php } ?>
   
 ***************
 *** 153,158 ****
 --- 199,205 ----
    | <?php _navigator('recent') ?>
    | <?php _navigator('help')   ?>
    ]
 +  <?php _toolbar('rss10', 36, 14) ?>
   
   <?php if ($trackback) { ?> &nbsp;
    [ <?php _navigator('trackback', $lang['trackback'] . '(' . tb_count($_page) . ')',
 ***************
 *** 161,166 ****
 --- 208,214 ----
   <?php if ($referer)   { ?> &nbsp;
    [ <?php _navigator('refer') ?> ]
   <?php } ?>
 + 
   <?php } // PKWK_SKIN_SHOW_NAVBAR ?>
   </div>
   
 ***************
 *** 197,240 ****
   <?php if (PKWK_SKIN_SHOW_TOOLBAR) { ?>
   <!-- Toolbar -->
   <div id="toolbar">
 - <?php
 - 
 - // Set toolbar-specific images
 - $_IMAGE['skin']['reload']   = 'reload.png';
 - $_IMAGE['skin']['new']      = 'new.png';
 - $_IMAGE['skin']['edit']     = 'edit.png';
 - $_IMAGE['skin']['freeze']   = 'freeze.png';
 - $_IMAGE['skin']['unfreeze'] = 'unfreeze.png';
 - $_IMAGE['skin']['diff']     = 'diff.png';
 - $_IMAGE['skin']['upload']   = 'file.png';
 - $_IMAGE['skin']['copy']     = 'copy.png';
 - $_IMAGE['skin']['rename']   = 'rename.png';
 - $_IMAGE['skin']['top']      = 'top.png';
 - $_IMAGE['skin']['list']     = 'list.png';
 - $_IMAGE['skin']['search']   = 'search.png';
 - $_IMAGE['skin']['recent']   = 'recentchanges.png';
 - $_IMAGE['skin']['backup']   = 'backup.png';
 - $_IMAGE['skin']['help']     = 'help.png';
 - $_IMAGE['skin']['rss']      = 'rss.png';
 - $_IMAGE['skin']['rss10']    = & $_IMAGE['skin']['rss'];
 - $_IMAGE['skin']['rss20']    = 'rss20.png';
 - $_IMAGE['skin']['rdf']      = 'rdf.png';
 - 
 - function _toolbar($key, $x = 20, $y = 20){
 - 	$lang  = & $GLOBALS['_LANG']['skin'];
 - 	$link  = & $GLOBALS['_LINK'];
 - 	$image = & $GLOBALS['_IMAGE']['skin'];
 - 	if (! isset($lang[$key]) ) { echo 'LANG NOT FOUND';  return FALSE; }
 - 	if (! isset($link[$key]) ) { echo 'LINK NOT FOUND';  return FALSE; }
 - 	if (! isset($image[$key])) { echo 'IMAGE NOT FOUND'; return FALSE; }
 - 
 - 	echo '<a href="' . $link[$key] . '">' .
 - 		'<img src="' . IMAGE_DIR . $image[$key] . '" width="' . $x . '" height="' . $y . '" ' .
 - 			'alt="' . $lang[$key] . '" title="' . $lang[$key] . '" />' .
 - 		'</a>';
 - 	return TRUE;
 - }
 - ?>
    <?php _toolbar('top') ?>
   
   <?php if ($is_page) { ?>
 --- 245,250 ----
 ***************
 *** 270,287 ****
   </div>
   <?php } // PKWK_SKIN_SHOW_TOOLBAR ?>
   
 - <?php if ($lastmodified != '') { ?>
 - <div id="lastmodified">Last-modified: <?php echo $lastmodified ?></div>
 - <?php } ?>
 - 
 - <?php if ($related != '') { ?>
 - <div id="related">Link: <?php echo $related ?></div>
 - <?php } ?>
 - 
   <div id="footer">
 !  Site admin: <a href="<?php echo $modifierlink ?>"><?php echo $modifier ?></a><p />
    <?php echo S_COPYRIGHT ?>.
 !  Powered by PHP <?php echo PHP_VERSION ?>. HTML convert time: <?php echo $taketime ?> sec.
   </div>
   
   </body>
 --- 280,290 ----
   </div>
   <?php } // PKWK_SKIN_SHOW_TOOLBAR ?>
   
   <div id="footer">
 ! Site admin: <a href="<?php echo $modifierlink ?>"><?php echo $modifier ?></a><p />
    <?php echo S_COPYRIGHT ?>.
 !  Powered by 
 ! <a href="https://osdn.jp/"><img src="http://osdn.jp/sflogo.php?group_id=2915" width="96" height="31" border="0" alt="OSDN"></a>
 ! <a href="https://osdn.jp/"><img src="https://osdn.jp/sflogo.php?group_id=2915" width="96" height="31" border="0" alt="OSDN"></a>
   </div>
   
   </body>

***スパム対策 [#f0783e59]
以前のサイトではスパム対策を行っていたのだが,サーバのファイルが全部
アボーンしたので,そのカスタマイズも忘れてしまったが,
-[[にゅう すらどふう:http://im-ltd.ath.cx/pukiwiki/?PukiwikiSpam]] さんの Pukiwikiのスパム対策

というページに,私が書いた「平仮名を含んでいない書き込みを認めない」
check_kanamoji() 関数が掲載されていた.探せばあるものですね,一安心.

 534a535,557
 > <?php
 > function check_kanamoji($line){
 >     // 一度入力文字コードを EUC に統一する
 >     $buf = mb_convert_encoding($line, "EUC-JP", "auto");
 >     // バッファの中にひらがなのコードが含まれているかどうかを判定する
 >     $result = preg_match("/(\xA4[\xA1-\xF3])/i", $line);
 >     if (!$result){
 >         die_message('申し訳ありませんがスパムと判定しました。');
 >     }
 > }
 > // 文字列のうちURLが30%を超えていたらスパムと判定
 > function check_url_rate($s) {
 >     $len = strlen($s);
 >     $regex = '|s?https?://[-_.!~*\'()a-zA-Z0-9;/?:@&=+$,%#]+|';
 >     $n = preg_match_all($regex, $s, $matches);
 >     for($i = 0; $i < $n; $i++) {
 >         $urllen += strlen($matches[0][$i]);
 >     }
 >     if(($urllen / $len) > 0.30) {
 >         die_message('申し訳ありませんがスパムと判定しました。');
 >     }
 > }
 > ?>
 \ No newline at end of file


ページの編集にはパスワードを入力しなければならないので,
comment.inc.php と pcomment.inc.php の二つのファイルを改変すれば OK.

 *** comment.inc.php~   2007-07-01 18:48:29.000000000 +0900
 --- comment.inc.php    2007-07-01 18:49:26.000000000 +0900
 ***************
 *** 36,41 ****
 --- 36,44 ----
        }
        if ($vars['msg'] == '') return array('msg'=>'', 'body'=>''); // Do nothing
   
 +      check_kanamoji($vars['msg']);
 +      check_url_rate($vars['msg']);
 + 
        $comment  = str_replace('$msg', $vars['msg'], PLUGIN_COMMENT_FORMAT_MSG);
        if(isset($vars['name']) || ($vars['nodate'] != '1')) {
                $_name = (! isset($vars['name']) || $vars['name'] == '') ? $_no_name : $vars['name'];


 *** pcomment.inc.php~  2007-07-01 18:48:34.000000000 +0900
 --- pcomment.inc.php   2007-07-01 18:49:12.000000000 +0900
 ***************
 *** 51,56 ****
 --- 51,59 ----
        if (! isset($vars['msg']) || $vars['msg'] == '') return array();
        $refer = isset($vars['refer']) ? $vars['refer'] : '';
   
 +      check_kanamoji($vars['msg']);
 +      check_url_rate($vars['msg']);
 + 
        $retval = plugin_pcomment_insert();
        if ($retval['collided']) {
                $vars['page'] = $refer;