"PukiWiki" '.S_VERSION.' Copyright © 2001-2004
PukiWiki Developers Team.
License is GNU/GPL.
Based on "PukiWiki" 1.3 by sng
');
/////////////////////////////////////////////////
// 初期設定 (サーバ変数)
foreach (array('SCRIPT_NAME', 'SERVER_ADMIN', 'SERVER_NAME',
'SERVER_PORT', 'SERVER_SOFTWARE') as $key) {
define($key, isset($_SERVER[$key]) ? $_SERVER[$key] : '');
unset(${$key}, $_SERVER[$key], $HTTP_SERVER_VARS[$key]);
}
/////////////////////////////////////////////////
// 初期設定 (グローバル変数)
// 脚注
$foot_explain = array();
// 関連するページ
$related = array();
//
内に追加するタグ
$head_tags = array();
/////////////////////////////////////////////////
// 初期設定(時間)
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))) {
$die = "${die}File is not found. ($file)\n";
} else {
require(constant($file));
}
}
if ($die) { die_message(nl2br("\n\n" . $die)); }
/////////////////////////////////////////////////
// INI_FILE: $script: 初期設定
if (!isset($script) or $script == '') {
$script = get_script_uri();
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.');
}
}
/////////////////////////////////////////////////
// INI_FILE: $agents: UserAgentの識別
$ua = 'HTTP_USER_AGENT';
$user_agent = $matches = array();
$user_agent['agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
unset(${$ua}, $_SERVER[$ua], $HTTP_SERVER_VARS[$ua], $ua); // safety
foreach ($agents as $agent) {
if (preg_match($agent['pattern'], $user_agent['agent'], $matches)) {
$user_agent['profile'] = isset($agent['profile']) ? $agent['profile'] : '';
$user_agent['name'] = isset($matches[1]) ? $matches[1] : ''; // device or browser name
$user_agent['vers'] = isset($matches[2]) ? $matches[2] : ''; // 's version
break;
}
}
unset($agents, $matches);
// Profile-related init and setting
define('UA_PROFILE', isset($user_agent['profile']) ? $user_agent['profile'] : '');
//// Not needed now
// define('INI_PRO_FILE', SUB_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)) {
die_message('UA_INI_FILE for "' . UA_PROFILE . '" not found.');
} else {
require(UA_INI_FILE); // Also manually
}
define('UA_NAME', isset($user_agent['name']) ? $user_agent['name'] : '');
define('UA_VERS', isset($user_agent['vers']) ? $user_agent['vers'] : '');
unset($user_agent); // Unset after reading UA_INI_FILE
/////////////////////////////////////////////////
// ディレクトリのチェック
$die = '';
foreach(array('DATA_DIR', 'DIFF_DIR', 'BACKUP_DIR', 'CACHE_DIR') as $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 ($temp) {
if ($die) { $die .= "\n"; } // A breath
$die = "${die}Variable(s) not found: (Maybe the old *.ini.php?)\n" . $temp;
}
$temp = '';
foreach(array('LANG', 'PLUGIN_DIR') as $def){
if (!defined($def)) $temp .= "$def\n";
}
if ($temp) {
if ($die) { $die .= "\n"; } // A breath
$die = "${die}Define(s) not found: (Maybe the old *.ini.php?)\n" . $temp;
}
if($die){ die_message(nl2br("\n\n" . $die)); }
unset($die, $temp);
/////////////////////////////////////////////////
// 必須のページが存在しなければ、空のファイルを作成する
foreach(array($defaultpage, $whatsnew, $interwiki) as $page){
if (!is_page($page)) { touch(get_filename($page)); }
}
/////////////////////////////////////////////////
// 外部からくる変数をチェック
// Prohibit $_GET attack
foreach (array('msg', 'pass') as $key) {
if (isset($_GET[$key])) die_message("Sorry, already reserved: $key=");
}
$_GET = input_filter($_GET); $get = & $_GET;
$_POST = input_filter($_POST); $post = & $_POST;
$_COOKIE = input_filter($_COOKIE); $cookie = & $_COOKIE;
// Expire risk
unset($HTTP_GET_VARS, $HTTP_POST_VARS); //, 'SERVER', 'ENV', 'SESSION', ...
/////////////////////////////////////////////////
// 文字コードを変換
//