/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: init.php,v 1.55 2003/07/05 01:31:55 arino Exp $
+// $Id: init.php,v 1.56 2003/07/05 04:46:34 arino Exp $
//
/////////////////////////////////////////////////
define('LANG','ja');
mb_internal_encoding(SOURCE_ENCODING);
mb_http_output(SOURCE_ENCODING);
-mb_detect_order('ASCII,JIS,EUC,UTF-8,SJIS');
-// mb_detect_order('ASCII,JIS,UTF-8,EUC,SJIS'); // UTF-8¤òÍ¥À褹¤ë¾ì¹ç
/////////////////////////////////////////////////
// ½é´üÀßÄê(ÀßÄê¥Õ¥¡¥¤¥ë¤Î¾ì½ê)
$post = sanitize($_POST);
$cookie = sanitize($_COOKIE);
-// ¥Ý¥¹¥È¤µ¤ì¤¿Ê¸»ú¤Î¥³¡¼¥É¤òÊÑ´¹
-mb_convert_variables(SOURCE_ENCODING,'auto',$get,$post);
+/////////////////////////////////////////////////
+// ʸ»ú¥³¡¼¥É¤òÊÑ´¹
+
+// <form> ¤ÇÁ÷¿®¤µ¤ì¤¿Ê¸»ú (¥Ö¥é¥¦¥¶¤¬¥¨¥ó¥³¡¼¥É¤·¤¿¥Ç¡¼¥¿) ¤Î¥³¡¼¥É¤òÊÑ´¹
+// post ¤Ï¾ï¤Ë <form> ¤Ê¤Î¤Ç¡¢É¬¤ºÊÑ´¹
+if (array_key_exists('encode_hint',$post))
+{
+ // html.php ¤ÎÃæ¤Ç¡¢<form> ¤Ë encode_hint ¤ò»Å¹þ¤ó¤Ç¤¤¤ë¤Î¤Ç¡¢É¬¤º encode_hint ¤¬¤¢¤ë¤Ï¤º¡£
+ // encode_hint ¤Î¤ß¤òÍѤ¤¤Æ¥³¡¼¥É¸¡½Ð¤¹¤ë¡£
+ // Á´ÂΤò¸«¤Æ¥³¡¼¥É¸¡½Ð¤¹¤ë¤È¡¢µ¡¼ï°Í¸ʸ»ú¤ä¡¢Ì¯¤Ê¥Ð¥¤¥Ê¥ê¥³¡¼¥É¤¬º®Æþ¤·¤¿¾ì¹ç¤Ë¡¢
+ // ¥³¡¼¥É¸¡½Ð¤Ë¼ºÇÔ¤¹¤ë¶²¤ì¤¬¤¢¤ë¤¿¤á¡£
+ $encode = mb_detect_encoding($post['encode_hint']);
+ mb_convert_variables(SOURCE_ENCODING,$encode,$post);
+}
+else if (count($post) > 0)
+{
+ // encode_hint ¤¬Ìµ¤¤¤È¤¤¤¦¤³¤È¤Ï¡¢Ìµ¤¤¤Ï¤º¡£
+ // ¥Ç¥Ð¥Ã¥°ÍѤˡ¢¼è¤ê¤¢¤¨¤º¡¢·Ù¹ð¥á¥Ã¥»¡¼¥¸¤ò½Ð¤·¤Æ¤ª¤¤Þ¤¹¡£
+ echo "<p>Warning: 'encode_hint' field is not found in the posted data.</p>\n";
+ // Á´Éô¤Þ¤È¤á¤Æ¡¢¥³¡¼¥É¸¡½Ð¡¢ÊÑ´¹
+ mb_convert_variables(SOURCE_ENCODING,'auto',$post);
+}
+
+// get ¤Ï <form> ¤«¤é¤Î¾ì¹ç¤È¡¢<a href="http;//script/?query> ¤Î¾ì¹ç¤¬¤¢¤ë
+if (array_key_exists('encode_hint',$get))
+{
+ // <form> ¤Î¾ì¹ç¤Ï¡¢¥Ö¥é¥¦¥¶¤¬¥¨¥ó¥³¡¼¥É¤·¤Æ¤¤¤ë¤Î¤Ç¡¢¥³¡¼¥É¸¡½Ð¡¦ÊÑ´¹¤¬É¬Íס£
+ // encode_hint ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¤Ï¤º¤Ê¤Î¤Ç¡¢¤½¤ì¤ò¸«¤Æ¡¢¥³¡¼¥É¸¡½Ð¤·¤¿¸å¡¢ÊÑ´¹¤¹¤ë¡£
+ // Íýͳ¤Ï¡¢post ¤ÈƱÍÍ
+ $encode = mb_detect_encoding($get['encode_hint']);
+ mb_convert_variables(SOURCE_ENCODING,$encode,$get);
+}
+// <a href...> ¤Î¾ì¹ç¤Ï¡¢¥µ¡¼¥Ð¡¼¤¬ rawurlencode ¤·¤Æ¤¤¤ë¤Î¤Ç¡¢¥³¡¼¥ÉÊÑ´¹¤ÏÉÔÍ×
+
+// QUERY_STRING¤ò¼èÆÀ
+// cmd¤âplugin¤â»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢QUERY_STRING¤ò¥Ú¡¼¥¸Ì¾¤«InterWikiName¤Ç¤¢¤ë¤È¤ß¤Ê¤¹°Ù
+// ¤Þ¤¿¡¢URI ¤ò urlencode ¤»¤º¤Ë¼êÂǤÁ¤ÇÆþÎϤ·¤¿¾ì¹ç¤ËÂн褹¤ë°Ù
+if ($_SERVER['QUERY_STRING'] != '')
+{
+ $arg = $_SERVER['QUERY_STRING'];
+}
+else if (array_key_exists(0,$_SERVER['argv']))
+{
+ $arg = $_SERVER['argv'][0];
+}
+
+// ¥µ¥Ë¥¿¥¤¥º (\0 ½üµî)
+$arg = sanitize($arg);
-if (!empty($get['page'])) {
+// URI ¼êÂǤξì¹ç¡¢¥³¡¼¥ÉÊÑ´¹¤·¡¢get[] ¤Ë¾å½ñ¤
+mb_convert_variables(SOURCE_ENCODING,'auto',$arg);
+foreach (explode('&',$arg) as $tmp_string)
+{
+ if (preg_match('/^([^=]+)=(.+)/',$tmp_string,$matches)
+ and mb_detect_encoding($matches[2]) != 'ASCII')
+ {
+ $get[$matches[1]] = $matches[2];
+ }
+}
+
+if (!empty($get['page']))
+{
$get['page'] = strip_bracket($get['page']);
}
-if (!empty($post['page'])) {
+if (!empty($post['page']))
+{
$post['page'] = strip_bracket($post['page']);
}
-if (!empty($post['msg'])) {
+if (!empty($post['msg']))
+{
$post['msg'] = str_replace("\r",'',$post['msg']);
}
$vars = array_merge($post,$get);
-if (!array_key_exists('page',$vars)) {
+if (!array_key_exists('page',$vars))
+{
$get['page'] = $post['page'] = $vars['page'] = '';
}
// ¸åÊý¸ß´¹À (?md5=...)
-if (array_key_exists('md5',$vars) and $vars['md5'] != '') {
+if (array_key_exists('md5',$vars) and $vars['md5'] != '')
+{
$vars['cmd'] = 'md5';
}
// cmd¤âplugin¤â»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢QUERY_STRING¤ò¥Ú¡¼¥¸Ì¾¤«InterWikiName¤Ç¤¢¤ë¤È¤ß¤Ê¤¹
if (!array_key_exists('cmd',$vars) and !array_key_exists('plugin',$vars))
{
- if ($_SERVER['QUERY_STRING'] != '')
- {
- $arg = $_SERVER['QUERY_STRING'];
- }
- else if (array_key_exists(0,$_SERVER['argv']))
- {
- $arg = $_SERVER['argv'][0];
- }
- else
+ if ($arg == '')
{
//¤Ê¤Ë¤â»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï$defaultpage¤òɽ¼¨
$arg = $defaultpage;
/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: mbstring.php,v 1.1 2003/07/03 05:31:39 arino Exp $
+// $Id: mbstring.php,v 1.2 2003/07/05 04:46:35 arino Exp $
//
/*
}
// mb_convert_variables -- ÊÑ¿ô¤Îʸ»ú¥³¡¼¥É¤òÊÑ´¹¤¹¤ë
-function mb_convert_variables($to_encoding,$from_encoding,&$get,&$post)
+function mb_convert_variables($to_encoding,$from_encoding,&$vars)
{
- // Ãí: ²ÄÊÑĹ°ú¿ô¤Ç¤Ï¤Ê¤¤¡£init.php¤«¤é¸Æ¤Ð¤ì¤ë2°ú¿ô¤Î¤ß¤ò¥µ¥Ý¡¼¥È
+ // Ãí: ²ÄÊÑĹ°ú¿ô¤Ç¤Ï¤Ê¤¤¡£init.php¤«¤é¸Æ¤Ð¤ì¤ë1°ú¿ô¤Î¥Ñ¥¿¡¼¥ó¤Î¤ß¤ò¥µ¥Ý¡¼¥È
// ÀµÄ¾¤Ë¼ÂÁõ¤¹¤ë¤Ê¤é¡¢²ÄÊÑ°ú¿ô¤ò¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¼õ¤±¤ëÊýË¡¤¬É¬Í×
- $encoding = mb_detect_encoding(join_array(' ',array_merge($get,$post)));
- if ($encoding != 'ASCII' and $encoding != SOURCE_ENCODING)
+ if (is_array($from_encoding) or $from_encoding == '' or $from_encoding == 'auto')
{
- foreach ($get as $key=>$value)
- {
- $get[$key] = mb_convert_encoding($value,$to_encoding,$encode);
- }
- foreach ($post as $key=>$value)
+ $from_encoding = mb_detect_encoding(join_array(' ',$vars));
+ }
+ if ($from_encoding != 'ASCII' and $from_encoding != SOURCE_ENCODING)
+ {
+ foreach ($vars as $key=>$value)
{
- $post[$key] = mb_convert_encoding($value,$to_encoding,$encode);
+ $vars[$key] = mb_convert_encoding($value,$to_encoding,$from_encoding);
}
}
- return $encoding;
+ return $from_encoding;
}
// Êä½õ´Ø¿ô:ÇÛÎó¤òºÆµ¢Åª¤Ëjoin¤¹¤ë