OSDN Git Service

BugTrack/133, BugTrack/118, BugTrack/136, BugTrack/134, BugTrack/128, BugTrack/120を一気に投入
[pukiwiki/pukiwiki.git] / init.php
1 <?
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: init.php,v 1.13 2002/08/21 17:32:04 masui Exp $
4 /////////////////////////////////////////////////
5
6 // ÀßÄê¥Õ¥¡¥¤¥ë¤Î¾ì½ê
7 define("INI_FILE","./pukiwiki.ini.php");
8
9 //** ½é´üÀßÄê **
10
11 ini_set('error_reporting', 5);
12 define("S_VERSION","1.3.2");
13 define("S_COPYRIGHT","<strong>\"PukiWiki\" ".S_VERSION."</strong> Copyright &copy; 2001,2002 <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/sng/\">sng</a>");
14 define("UTIME",time());
15 define("HTTP_USER_AGENT",$HTTP_SERVER_VARS["HTTP_USER_AGENT"]);
16 define("PHP_SELF",$HTTP_SERVER_VARS["PHP_SELF"]);
17 define("SERVER_NAME",$HTTP_SERVER_VARS["SERVER_NAME"]);
18
19 define("MUTIME",getmicrotime());
20
21 if($script == "") {
22         $script = 'http://'.getenv('SERVER_NAME').(getenv('SERVER_PORT')==80?'':(':'.getenv('SERVER_PORT'))).getenv('SCRIPT_NAME');
23 }
24
25 $WikiName = '([A-Z][a-z]+([A-Z][a-z]+)+)';
26 $BracketName = '\[\[(\[*[^\s\]]+?\]*)\]\]';
27 $InterWikiName = '\[\[(\[*[^\s\]]+?\]*):(\[*[^>\]]+?\]*)\]\]';
28 $InterWikiNameNoBracket = '(\[*[^\s\]]+?\]*):(\[*[^>\]]+?\]*)';
29
30 //** ÆþÎÏÃͤÎÀ°·Á **
31
32 $cookie = $HTTP_COOKIE_VARS;
33
34 if(get_magic_quotes_gpc())
35 {
36         foreach($HTTP_GET_VARS as $key => $value) {
37                 $get[$key] = stripslashes($HTTP_GET_VARS[$key]);
38         }
39         foreach($HTTP_POST_VARS as $key => $value) {
40                 $post[$key] = stripslashes($HTTP_POST_VARS[$key]);
41         }
42         foreach($HTTP_COOKIE_VARS as $key => $value) {
43                 $cookie[$key] = stripslashes($HTTP_COOKIE_VARS[$key]);
44         }
45 }
46 else {
47         $post = $HTTP_POST_VARS;
48         $get = $HTTP_GET_VARS;
49 }
50
51 if($post["msg"])
52 {
53         $post["msg"] = preg_replace("/((\x0D\x0A)|(\x0D)|(\x0A))/","\n",$post["msg"]);
54 }
55 if($get["page"]) $get["page"] = rawurldecode($get["page"]);
56 if($post["word"]) $post["word"] = rawurldecode($post["word"]);
57 if($get["word"]) $get["word"] = rawurldecode($get["word"]);
58
59 $vars = array_merge($post,$get);
60 $arg = rawurldecode((getenv('QUERY_STRING') != '')?
61                     getenv('QUERY_STRING') :
62                     $HTTP_SERVER_VARS["argv"][0]);
63
64 // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɹþ
65 @require(INI_FILE);
66 @require(LANG.".lng");
67
68 //** ½é´ü½èÍý **
69 $update_exec = "";
70 $content_id = 0;
71
72 if($usefacemark) {
73   $line_rules = array_merge($line_rules,$facemark_rules);
74 }
75 $user_rules = array_merge($str_rules,$line_rules);
76
77 $note_id = 1;
78 $foot_explain = array();
79
80 // ÊÑ¿ô¤Î¥Á¥§¥Ã¥¯
81 if(php_sapi_name()=='cgi' && !preg_match("/^http:\/\/[-a-zA-Z0-9\@:;_.]+\//",$script))
82         die_message("please set '\$script' in ".INI_FILE);
83
84
85 // ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÊÑ¿ô¥Á¥§¥Ã¥¯
86 $wrong_ini_file = "";
87 if(!isset($rss_max)) $wrong_ini_file .= '$rss_max ';
88 if(!isset($page_title)) $wrong_ini_file .= '$page_title ';
89 if(!isset($note_hr)) $wrong_ini_file .= '$note_hr ';
90 if(!isset($related_link)) $wrong_ini_file .= '$related_link ';
91 if(!isset($show_passage)) $wrong_ini_file .= '$show_passage ';
92 if(!isset($rule_related_str)) $wrong_ini_file .= '$rule_related_str ';
93 if(!isset($load_template_func)) $wrong_ini_file .= '$load_template_func ';
94 if(!defined("LANG")) $wrong_ini_file .= 'LANG ';
95 if(!defined("PLUGIN_DIR")) $wrong_ini_file .= 'PLUGIN_DIR ';
96
97 if(!is_writable(DATA_DIR))
98         die_message("DATA_DIR is not found or not writable.");
99 if(!is_writable(DIFF_DIR))
100         die_message("DIFF_DIR is not found or not writable.");
101 if($do_backup && !is_writable(BACKUP_DIR))
102         die_message("BACKUP_DIR is not found or not writable.");
103 if(!file_exists(INI_FILE))
104         die_message("INI_FILE is not found.");
105 if($wrong_ini_file)
106         die_message("The setting file runs short of information.<br>The version of a setting file may be old.<br><br>These option are not found : $wrong_ini_file");
107 //if(ini_get("register_globals") !== "0")
108 //      die_message("Wrong PHP4 setting in 'register_globals',set value 'Off' to httpd.conf or .htaccess.");
109 if(!file_exists(SKIN_FILE))
110         die_message("SKIN_FILE is not found.");
111 if(!file_exists(LANG.".lng"))
112         die_message(LANG.".lng(language file) is not found.");
113
114 if(!file_exists(get_filename(encode($defaultpage))))
115         touch(get_filename(encode($defaultpage)));
116 if(!file_exists(get_filename(encode($whatsnew))))
117         touch(get_filename(encode($whatsnew)));
118 if(!file_exists(get_filename(encode($interwiki))))
119         touch(get_filename(encode($interwiki)));
120
121 $ins_date = date($date_format,UTIME);
122 $ins_time = date($time_format,UTIME);
123 $ins_week = "(".$weeklabels[date("w",UTIME)].")";
124
125 $now = "$ins_date $ins_week $ins_time";
126
127 ?>