/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: init.php,v 1.3 2004/08/04 14:38:10 henoheno Exp $
+// $Id: init.php,v 1.4 2004/08/09 11:19:08 henoheno Exp $
//
/////////////////////////////////////////////////
/////////////////////////////////////////////////
// ½é´üÀßÄê (ʸ»ú¥¨¥ó¥³¡¼¥É¡¢¸À¸ì)
-define('LANG','ja'); // Select 'ja' or 'en'
-define('SOURCE_ENCODING','EUC-JP');
+define('LANG', 'ja'); // Select 'ja' or 'en'
+define('SOURCE_ENCODING', 'EUC-JP');
// mbstring extension ´ØÏ¢
mb_language('Japanese');
/////////////////////////////////////////////////
// ½é´üÀßÄê (¥Ð¡¼¥¸¥ç¥ó/Ãøºî¸¢)
-define('S_VERSION','1.4.4rc1');
-define('S_COPYRIGHT','
-<strong>"PukiWiki" '.S_VERSION.'</strong> Copyright © 2001-2004
-<a href="http://pukiwiki.org">PukiWiki Developers Team</a>.
-License is <a href="http://www.gnu.org/">GNU/GPL</a>.<br />
-Based on "PukiWiki" 1.3 by <a href="http://factage.com/yu-ji/">yu-ji</a>
-');
+define('S_VERSION', '1.4.4rc1');
+define('S_COPYRIGHT',
+ '<strong>PukiWiki ' . S_VERSION . '</strong>' .
+ ' Copyright © 2001-2004' .
+ ' <a href="http://pukiwiki.org">PukiWiki Developers Team</a>.' .
+ ' License is <a href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br />' .
+ ' Based on "PukiWiki" 1.3 by <a href="http://factage.com/yu-ji/">yu-ji</a>'
+);
/////////////////////////////////////////////////
// ½é´üÀßÄê (¥µ¡¼¥ÐÊÑ¿ô)
/////////////////////////////////////////////////
// ½é´üÀßÄê (¥°¥í¡¼¥Ð¥ëÊÑ¿ô)
-// µÓÃí
-$foot_explain = array();
-// ´ØÏ¢¤¹¤ë¥Ú¡¼¥¸
-$related = array();
-// <head>Æâ¤ËÄɲ乤륿¥°
-$head_tags = array();
+$foot_explain = array(); // µÓÃí
+$related = array(); // ´ØÏ¢¤¹¤ë¥Ú¡¼¥¸
+$head_tags = array(); // <head>Æâ¤ËÄɲ乤륿¥°
/////////////////////////////////////////////////
// ½é´üÀßÄê(»þ´Ö)
-define('LOCALZONE',date('Z'));
-define('UTIME',time() - LOCALZONE);
-define('MUTIME',getmicrotime());
+define('LOCALZONE', date('Z'));
+define('UTIME', time() - LOCALZONE);
+define('MUTIME', getmicrotime());
/////////////////////////////////////////////////
// ¥Õ¥¡¥¤¥ëÆɤ߹þ¤ß
$die = '';
foreach(array('LANG_FILE', 'INI_FILE') as $file){
- if (!file_exists(constant($file)) || !is_readable(constant($file))) {
+ if (! file_exists(constant($file)) || ! is_readable(constant($file))) {
$die = "${die}File is not found. ($file)\n";
} else {
require(constant($file));
/////////////////////////////////////////////////
// INI_FILE: $script: ½é´üÀßÄê
-if (!isset($script) or $script == '') {
+if (! isset($script) or $script == '') {
$script = get_script_uri();
- if ($script === FALSE or (php_sapi_name() == 'cgi' and !is_url($script,TRUE))) {
+ if ($script === FALSE or (php_sapi_name() == 'cgi' and ! is_url($script, TRUE))) {
die_message('get_script_uri() failed: Please set $script at INI_FILE manually.');
}
}
// Profile-related init and setting
define('UA_PROFILE', isset($user_agent['profile']) ? $user_agent['profile'] : '');
-//// Not needed now
-// define('INI_PRO_FILE', LIB_DIR . 'init.' . UA_PROFILE . '.php');
-// if (file_exists(INI_PRO_FILE) && is_readable(INI_PRO_FILE)) {
-// require(INI_PRO_FILE); // A chance to set or rewrite $user_agent['name'] and ['vers'] automatically
-// }
-
define('UA_INI_FILE', DATA_HOME . UA_PROFILE . '.ini.php');
-if (!file_exists(UA_INI_FILE) || !is_readable(UA_INI_FILE)) {
+if (! file_exists(UA_INI_FILE) || ! is_readable(UA_INI_FILE)) {
die_message('UA_INI_FILE for "' . UA_PROFILE . '" not found.');
} else {
require(UA_INI_FILE); // Also manually
$die = '';
foreach(array('DATA_DIR', 'DIFF_DIR', 'BACKUP_DIR', 'CACHE_DIR') as $dir){
- if(!is_writable(constant($dir))) {
+ if (! is_writable(constant($dir))) {
$die = "${die}Directory is not found or not writable ($dir)\n";
}
}
$temp = '';
foreach(array('rss_max', 'page_title', 'note_hr', 'related_link', 'show_passage',
'rule_related_str', 'load_template_func') as $var){
- if (!isset(${$var})) { $temp .= "\$$var\n"; }
+ if (! isset(${$var})) { $temp .= "\$$var\n"; }
}
if ($temp) {
if ($die) { $die .= "\n"; } // A breath
$temp = '';
foreach(array('LANG', 'PLUGIN_DIR') as $def){
- if (!defined($def)) $temp .= "$def\n";
+ if (! defined($def)) $temp .= "$def\n";
}
if ($temp) {
if ($die) { $die .= "\n"; } // A breath
// ɬ¿Ü¤Î¥Ú¡¼¥¸¤¬Â¸ºß¤·¤Ê¤±¤ì¤Ð¡¢¶õ¤Î¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ë
foreach(array($defaultpage, $whatsnew, $interwiki) as $page){
- if (!is_page($page)) { touch(get_filename($page)); }
+ if (! is_page($page)) { touch(get_filename($page)); }
}
/////////////////////////////////////////////////
-// ³°Éô¤«¤é¤¯¤ëÊÑ¿ô¤ò¥Á¥§¥Ã¥¯
+// ³°Éô¤«¤é¤¯¤ëÊÑ¿ô¤Î¥Á¥§¥Ã¥¯
// Prohibit $_GET attack
foreach (array('msg', 'pass') as $key) {
// Expire risk
unset($HTTP_GET_VARS, $HTTP_POST_VARS); //, 'SERVER', 'ENV', 'SESSION', ...
-unset($_REQUEST); // Seems not reliable
+unset($_REQUEST); // Considered harmful
// Remove null character etc.
$_GET = input_filter($_GET);
// ʸ»ú¥³¡¼¥ÉÊÑ´¹ ($_POST)
// <form> ¤ÇÁ÷¿®¤µ¤ì¤¿Ê¸»ú (¥Ö¥é¥¦¥¶¤¬¥¨¥ó¥³¡¼¥É¤·¤¿¥Ç¡¼¥¿) ¤Î¥³¡¼¥É¤òÊÑ´¹
// POST method ¤Ï¾ï¤Ë form ·Ðͳ¤Ê¤Î¤Ç¡¢É¬¤ºÊÑ´¹¤¹¤ë
-if (isset($_POST['encode_hint']) && $_POST['encode_hint'] != '')
-{
+//
+if (isset($_POST['encode_hint']) && $_POST['encode_hint'] != '') {
// html.php ¤ÎÃæ¤Ç¡¢<form> ¤Ë encode_hint ¤ò»Å¹þ¤ó¤Ç¤¤¤ë¤Î¤Ç¡¢
// encode_hint ¤òÍѤ¤¤Æ¥³¡¼¥É¸¡½Ð¤¹¤ë¡£
// Á´ÂΤò¸«¤Æ¥³¡¼¥É¸¡½Ð¤¹¤ë¤È¡¢µ¡¼ï°Í¸ʸ»ú¤ä¡¢Ì¯¤Ê¥Ð¥¤¥Ê¥ê
// ¥³¡¼¥É¤¬º®Æþ¤·¤¿¾ì¹ç¤Ë¡¢¥³¡¼¥É¸¡½Ð¤Ë¼ºÇÔ¤¹¤ë¶²¤ì¤¬¤¢¤ë¡£
$encode = mb_detect_encoding($_POST['encode_hint']);
mb_convert_variables(SOURCE_ENCODING, $encode, $_POST);
-}
-else if (isset($_POST['charset']) && $_POST['charset'] != '')
-{
- // TrackBack Ping¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤³¤È¤¬¤¢¤ë
- // »ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢¤½¤ÎÆâÍƤÇÊÑ´¹¤ò»î¤ß¤ë
- // ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¥³¡¼¥É¸¡½Ð¤ÎÀßÄê¤ÇÊÑ´¹¤·¤Ê¤ª¤·
- if (mb_convert_variables(SOURCE_ENCODING, $_POST['charset'], $_POST) !== $_POST['charset'])
+
+} else if (isset($_POST['charset']) && $_POST['charset'] != '') {
+ // TrackBack Ping ¤Ç»ØÄꤵ¤ì¤Æ¤¤¤ë¤³¤È¤¬¤¢¤ë
+ // ¤¦¤Þ¤¯¤¤¤«¤Ê¤¤¾ì¹ç¤Ï¼«Æ°¸¡½Ð¤ËÀÚ¤êÂؤ¨
+ if (mb_convert_variables(SOURCE_ENCODING,
+ $_POST['charset'], $_POST) !== $_POST['charset']) {
mb_convert_variables(SOURCE_ENCODING, 'auto', $_POST);
-}
-else if (count($_POST) > 0)
-{
- // ¥Ç¥Ð¥Ã¥°ÍѤˡ¢¼è¤ê¤¢¤¨¤º¡¢·Ù¹ð¥á¥Ã¥»¡¼¥¸¤ò½Ð¤·¤Æ¤ª¤¤Þ¤¹¡£
- // echo "<p>Warning: 'encode_hint' field is not found in the posted data.</p>\n";
+ }
- // Á´Éô¤Þ¤È¤á¤Æ¡¢¥³¡¼¥É¸¡½Ð¡¢ÊÑ´¹
+} else if (! empty($_POST)) {
+ // Á´Éô¤Þ¤È¤á¤Æ¡¢¼«Æ°¸¡½Ð¡¿ÊÑ´¹
mb_convert_variables(SOURCE_ENCODING, 'auto', $_POST);
}
// ʸ»ú¥³¡¼¥ÉÊÑ´¹ ($_GET)
// GET method ¤Ï form ¤«¤é¤Î¾ì¹ç¤È¡¢<a href="http://script/?key=value> ¤Î¾ì¹ç¤¬¤¢¤ë
+// <a href...> ¤Î¾ì¹ç¤Ï¡¢¥µ¡¼¥Ð¡¼¤¬ rawurlencode ¤·¤Æ¤¤¤ë¤Î¤Ç¡¢¥³¡¼¥ÉÊÑ´¹¤ÏÉÔÍ×
if (isset($_GET['encode_hint']) && $_GET['encode_hint'] != '')
{
// form ·Ðͳ¤Î¾ì¹ç¤Ï¡¢¥Ö¥é¥¦¥¶¤¬¥¨¥ó¥³¡¼¥É¤·¤Æ¤¤¤ë¤Î¤Ç¡¢¥³¡¼¥É¸¡½Ð¡¦ÊÑ´¹¤¬É¬Íס£
$encode = mb_detect_encoding($_GET['encode_hint']);
mb_convert_variables(SOURCE_ENCODING, $encode, $_GET);
}
-// <a href...> ¤Î¾ì¹ç¤Ï¡¢¥µ¡¼¥Ð¡¼¤¬ rawurlencode ¤·¤Æ¤¤¤ë¤Î¤Ç¡¢¥³¡¼¥ÉÊÑ´¹¤ÏÉÔÍ×
/////////////////////////////////////////////////
// cmd¤âplugin¤â»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢QUERY_STRING¤ò
// ¥Ú¡¼¥¸Ì¾¤«InterWikiName¤Ç¤¢¤ë¤È¤ß¤Ê¤¹
+$arg = '';
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']) {
$arg = $_SERVER['QUERY_STRING'];
} else if (isset($_SERVER['argv']) && count($_SERVER['argv'])) {
// $_SERVER['REQUEST_URI'] is used at func.php NOW
unset($REQUEST_URI, $HTTP_SERVER_VARS['REQUEST_URI']);
-// mb_convert_variables¤Î¥Ð¥°(?)Âкö ÇÛÎó¤ÇÅϤµ¤Ê¤¤¤ÈÍî¤Á¤ë
+// mb_convert_variables¤Î¥Ð¥°(?)Âкö: ÇÛÎó¤ÇÅϤµ¤Ê¤¤¤ÈÍî¤Á¤ë
$arg = array($arg);
mb_convert_variables(SOURCE_ENCODING, 'auto', $arg);
$arg = $arg[0];
$matches = array();
foreach (explode('&', $arg) as $key_and_value) {
if (preg_match('/^([^=]+)=(.+)/', $key_and_value, $matches) &&
- mb_detect_encoding($matches[2]) != 'ASCII')
+ mb_detect_encoding($matches[2]) != 'ASCII') {
$_GET[$matches[1]] = $matches[2];
+ }
}
unset($matches);
if (empty($_POST)) {
$vars = & $_GET; // Major pattern: Read-only access via GET
} else if (empty($_GET)) {
- $vars = & $_POST; // Minor pattern: Write access via POST
+ $vars = & $_POST; // Minor pattern: Write access via POST etc.
} else {
- $vars = array_merge($_GET, $_POST); // Seems more reliable than $_REQUEST
+ $vars = array_merge($_GET, $_POST); // Considered reliable than $_REQUEST
}
// ÆþÎÏ¥Á¥§¥Ã¥¯: cmd, plugin ¤Îʸ»úÎó¤Ï±Ñ¿ô»ú°Ê³°¤¢¤ê¤¨¤Ê¤¤
-foreach(array('cmd', 'plugin') as $var){
+foreach(array('cmd', 'plugin') as $var) {
if (array_key_exists($var, $vars) &&
! preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $vars[$var])) {
unset($get[$var], $post[$var], $vars[$var]);
}
// À°·Á: page, strip_bracket()
-if (array_key_exists('page', $vars)) {
+if (isset($vars['page'])) {
$get['page'] = $post['page'] = $vars['page'] = strip_bracket($vars['page']);
} else {
$get['page'] = $post['page'] = $vars['page'] = '';
// À°·Á: msg, ²þ¹Ô¤ò¼è¤ê½ü¤¯
if (isset($vars['msg'])) {
- $get['msg'] = $post['msg'] = $vars['msg'] = str_replace("\r",'',$vars['msg']);
+ $get['msg'] = $post['msg'] = $vars['msg'] = str_replace("\r", '', $vars['msg']);
}
// ¸åÊý¸ß´¹À (?md5=...)
-if (array_key_exists('md5', $vars) and $vars['md5'] != '') {
+if (isset($vars['md5']) && $vars['md5'] != '') {
$get['cmd'] = $post['cmd'] = $vars['cmd'] = 'md5';
}
// TrackBack Ping
-if (array_key_exists('tb_id', $vars) and $vars['tb_id'] != '') {
+if (isset($vars['tb_id']) && $vars['tb_id'] != '') {
$get['cmd'] = $post['cmd'] = $vars['cmd'] = 'tb';
}
// cmd¤âplugin¤â»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢QUERY_STRING¤ò¥Ú¡¼¥¸Ì¾¤«InterWikiName¤Ç¤¢¤ë¤È¤ß¤Ê¤¹
-if (!array_key_exists('cmd',$vars) and !array_key_exists('plugin',$vars))
-{
- if ($arg == '')
- {
- //¤Ê¤Ë¤â»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï$defaultpage¤òɽ¼¨
- $arg = $defaultpage;
- }
+if (! isset($vars['cmd']) && ! isset($vars['plugin'])) {
+
+ $get['cmd'] = $post['cmd'] = $vars['cmd'] = 'read';
+
+ if ($arg == '') $arg = $defaultpage;
$arg = rawurldecode($arg);
$arg = strip_bracket($arg);
$arg = input_filter($arg);
-
- $get['cmd'] = $post['cmd'] = $vars['cmd'] = 'read';
$get['page'] = $post['page'] = $vars['page'] = $arg;
}
// ¼ÂÂλ²¾È¥Ñ¥¿¡¼¥ó¤ª¤è¤Ó¥·¥¹¥Æ¥à¤Ç»ÈÍѤ¹¤ë¥Ñ¥¿¡¼¥ó¤ò$line_rules¤Ë²Ã¤¨¤ë
//$entity_pattern = '[a-zA-Z0-9]{2,8}';
-$entity_pattern = trim(join('',file(CACHE_DIR.'entities.dat')));
+$entity_pattern = trim(join('', file(CACHE_DIR . 'entities.dat')));
$line_rules = array_merge(array(
'&(#[0-9]+|#x[0-9a-f]+|' . $entity_pattern . ');' => '&$1;',